www.webdeveloper.com
Results 1 to 3 of 3

Thread: mysql count() range

  1. #1
    Join Date
    Jan 2004
    Posts
    484

    mysql count() range

    hi I have something like this

    tickets


    -----------------------------------
    |CreatedOn | IssueType |
    -----------------------------------
    |2007-12-04 11:29:43 | 'Phone' |
    |2007-12-04 11:29:43 | 'Web' |
    |2007-12-04 11:29:43 | 'Web' |
    |2007-12-05 11:29:43 | 'Web' |
    |2007-12-05 11:29:43 | 'Phone' |
    |2007-12-05 11:29:43 | 'Phone' |
    |2007-12-05 11:29:43 | 'Web' |
    |2007-12-06 11:29:43 | 'Web' |
    |2007-12-06 11:29:43 | 'Web' |
    |2007-12-06 11:29:43 | 'Phone' |
    |2007-12-06 11:29:43 | 'Phone' |
    |2007-12-06 11:29:43 | 'Web' |
    -----------------------------------


    I want this count how may 'web' for the date range?
    Like this

    -------------------------------
    |cDate |count(IssueType)|
    -------------------------------
    |2007-12-04 | 2 |
    |2007-12-05 | 2 |
    |2007-12-06 | 3 |
    -------------------------------

    This is what I have so far:

    Select Date(CreatedOn)as cDate, count(IssueType) from tickets where IssueType = 'Web' and CreatedOn >= '2007-12-04%' AND CreatedOn <= '2007-12-06%' group by CreatedOn


    and this is what I am getting

    -----------------------------------
    |cDate |count(IssueType)|
    -----------------------------------
    |2007-12-04 | 1 |
    |2007-12-04 | 1 |
    |2007-12-04 | 1 |
    |2007-12-05 | 1 |
    |2007-12-05 | 1 |
    |2007-12-05 | 1 |
    |2007-12-05 | 1 |
    |2007-12-06 | 1 |
    |2007-12-06 | 1 |
    |2007-12-06 | 1 |
    |2007-12-06 | 1 |
    |2007-12-06 | 1 |
    -----------------------------------

  2. #2
    Join Date
    Aug 2005
    Location
    The Garden State
    Posts
    5,634
    try using
    Code:
    group by date_format(date_column,'%Y-%m-%d')

  3. #3
    Join Date
    Jan 2004
    Posts
    484
    thanks
    I worked!

    It also worked like
    date(date_column)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles