>-----Original Message----- >From: Gavin Towey [mailto:gto...@ffn.com] >Sent: Wednesday, September 16, 2009 7:34 PM >To: John Meyer; mysql@lists.mysql.com >Subject: RE: Datediff function > >Hi John, > >You can't use aggregate function in the WHERE clause, because they aren't >evaluated until after the WHERE clause is applied. > [JS] You can use the HAVING clause, although it is probably inefficient.
Regards, Jerry Schwartz The Infoshop by Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 www.the-infoshop.com >Wouldn't it be much easier to simply keep a last_tweet_date field updated >somewhere then simply do >SELECT USER_NAME FROM USERS WHERE last_tweet_date < NOW()-INTERVAL 7 DAY; ? > >Regards, >Gavin Towey > >-----Original Message----- >From: John Meyer [mailto:johnme...@pueblocomputing.com] >Sent: Wednesday, September 16, 2009 12:52 PM >To: mysql@lists.mysql.com >Subject: Datediff function > >I'm trying to pull up a list of users who haven't tweeted in 7 or more >days, and I'm trying to use this statement: >SELECT USER_NAME, MAX(TWEET_CREATEDAT) FROM USERS NATURAL JOIN TWEETS >WHERE DATEDIFF(NOW(),MAX(TWEET_CREATEDAT)) > 7 GROUP BY USERS.USER_ID > >But it says "invalid group function". How should I reword this query? > >-- >MySQL General Mailing List >For list archives: http://lists.mysql.com/mysql >To unsubscribe: http://lists.mysql.com/mysql?unsub=gto...@ffn.com > > >The information contained in this transmission may contain privileged and >confidential information. It is intended only for the use of the person(s) >named above. If you are not the intended recipient, you are hereby notified >that any review, dissemination, distribution or duplication of this >communication is strictly prohibited. If you are not the intended recipient, >please contact the sender by reply email and destroy all copies of the >original >message. > >-- >MySQL General Mailing List >For list archives: http://lists.mysql.com/mysql >To unsubscribe: http://lists.mysql.com/mysql?unsub=jschwa...@the- >infoshop.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=arch...@jab.org