SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2005
    Posts
    527
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    select for a report

    I have a table with this fields :

    ID (integer)
    Date (datetime)
    Name (char)

    I want select count of items that add in each month of year
    For example a report like this :

    2 Items add to database in january of 2006
    9 Items add to database in march of 2006
    3 Items add to database in january of 2007

    (I can change the numbric month to it names with PHP)

  2. #2
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Code:
    select year(date) as theYear
         , month(date) as theMonth
         , count(*)
      from datable
    group
        by theYear
         , theMonth

  3. #3
    SitePoint Evangelist
    Join Date
    Dec 2005
    Posts
    527
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you


Bookmarks

Posting Permissions

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