SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Counting rows

  1. #1
    SitePoint Guru
    Join Date
    Dec 2001
    Location
    San Diego, CA
    Posts
    617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Counting rows

    I have entries in the table that are dated for when they were entered. I want to count the total entries for each month. How do I go about this?

    (I get paid per each entry, which is a purchase on the site, every month. That is what this is for.)

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    select date_format(entrydate, '%M %Y'), count(*)
    from some_table
    group by date_format(entrydate, '%Y%m')
    order by date_format(entrydate, '%Y%m')

    NB! Date format for sorting ("order by") is YYYYMM, date format in select clause is month name + year

  3. #3
    SitePoint Guru
    Join Date
    Dec 2001
    Location
    San Diego, CA
    Posts
    617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had to adapt it a little to do a few minor other things, but it worked perfectly! Makes sense to me too, so even better. Much appreciated


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
  •