Similarly, you can also use GROUP BY SELECT WHAT FROM TRANSACTION WHERE REGDATE < Now() -INTERVAL 15 DAY GROUP BY WHAT
The benefit of using GROUP BY as opposed to DISTINCT is that you can use the set of functions that work on groups like COUNT, SUM, MIN, MAX, etc... SELECT WHAT, COUNT(*) FROM TRANSACTION WHERE REGDATE < Now()-INTERVAL 15 DAY GROUP BY WHAT Would let you know how many times WHAT happened 15 days ago. Regards, Erik Osterman http://osterman.com/ -----Original Message----- From: Roger Baklund [mailto:[EMAIL PROTECTED] Sent: Sunday, November 09, 2003 10:06 AM To: [EMAIL PROTECTED] Cc: Admin-Stress Subject: Re: help on my query statement * Admin-Stress > I have a table called TRANSACTION, it has some fields : > > REGDATE - date of the transaction > WHAT - a string (NOT UNIQUE) > CUSTOMER - customer code > > I want to query all WHAT that the date of the transaction was 15 > days before. > > So, my sql query is : > > SELECT WHAT FROM TRANSACTION WHERE REGDATE < Now() -INTERVAL 15 DAY > > But, because of WHAT is not unique, then I could receive some > duplicates (customer can send some WHAT in the same REGDATE). > > How can I query only the unique WHAT ? I need to list all WHAT > (uniquely) that the date transaction was 15 days before. Looks like you need the DISTINCT keyword: <URL: http://www.mysql.com/doc/en/Selecting_columns.html#IDX391 > SELECT DISTINCT WHAT FROM TRANSACTION WHERE REGDATE < Now() -INTERVAL 15 DAY -- Roger -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]