Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2003
    Posts
    12

    Unanswered: GROUP BY day (with a date stamp column)

    I have a table as follows

    id date_time
    ---- ---------------------
    1 2003-10-04 12:09:00
    2 2003-10-04 13:09:00
    3 2003-10-05 12:09:00
    4 2003-10-05 14:09:00
    5 2003-10-06 14:09:00

    I want to have a count of each record in the same day. So my results should be

    total date
    ----------------------
    2 2003-10-04
    2 2003-10-05
    1 2003-10-06

    Any help?

  2. #2
    Join Date
    Sep 2003
    Location
    New York, NY
    Posts
    136
    try using this query:

    select CONVERT(varchar(10),date_time,120) as date, count(CONVERT(varchar(10),date_time,120)) as total
    from table_name
    group by CONVERT(varchar(10),date_time,120)

Posting Permissions

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