Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Location
    Netherlands
    Posts
    98

    Question Unanswered: Grouping by datecolumn

    Hi,

    i have a table which contains the following columns:

    Id = bigint id 1 +1
    Machineid = bigint
    logdate = datetime
    vtp = bigint,

    There are more records for 1 machine p/day
    i want to group them together by complete day and get the sum of vtp for every different machine for each day.

    Someone knows how to do this?
    Thanx in front!
    CHeers Wim

  2. #2
    Join Date
    Jan 2004
    Location
    In a large office with bad lighting
    Posts
    1,040
    select machineid, convert(char(10),logdate,120), sum(vtp)
    from <your_table>
    where <if any conditions apply>
    group by machineid, convert(char(10),logdate,120)
    order by machineid, convert(char(10),logdate,120)

    /*
    look up cast / convert in BOL for other date / time formats
    */

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •