SELECT COUNT(*) AS number_of_letters FROM tablename WHERE TO_DAYS(NOW()) -
TO_DAYS(datefield) <= 30 AND status='published' GROUP BY datefield;

But this won't return anything for the days when no letters has been
published though...

Gurhan


-----Original Message-----
From: John Hughes [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 01, 2002 1:02 PM
To: [EMAIL PROTECTED]
Subject: Query structure question


I have a database that tracks letters to the editor published in my
paper. The table includes a date field and a status field. Status can
be either "input" or "published."

What I want to do is create a report that tells me how many letters
were published on each of the last 30 days.

Is there a way to construct the query so that only one pass is made
at the database, or must I loop through the last 30 days counting how
many records have published status and equal date?

Any suggestions would be appreciated.

John Hughes

__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to