Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2014

    Unanswered: Mysql count by week help

    Hi All

    I have a database with a table called tickets, the table has many columns but basically the ones i want are date and subject
    date is stored as datetime eg 14-06-04 10:33:39
    subject column has many different entries but i would like to only select where subject Like 073

    I currently have a query that counts the number of occurrences per subject
    SELECT COUNT(*) AS `cnt`, `subject` FROM tickets GROUP BY `subject` ORDER BY `cnt`
    I would like to change this to count the total number of tickets per week where subject = 073

    output should look like

    Week Tickets
    01-06-14 5
    08-06-14 4
    15-06-14 2

    if anyone could help that would be greatly appreciated

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    several ways
    one is to create a table which defines your weeks, so you know when a week starts and/or ends, join your sales table to that.

    or use the week function and some modulus maths to workout what the end of the weeks date is
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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