matchoo Posted June 8, 2007 Share Posted June 8, 2007 Hi there, I have a log file with multiple records per day. I want to get the last log entry per page for a certain day only. select distinct date_stamp, page, hits from log won't work because there are different hit counts - so the query returns duplicate entries for a page how to get the last timestamp per day? (p.s. - I'm on 4.1 not 5) Quote Link to comment https://forums.phpfreaks.com/topic/54704-distinct-first-column-the-rest-not/ Share on other sites More sharing options...
bubblegum.anarchy Posted June 8, 2007 Share Posted June 8, 2007 Grab all the records on the condition of the 'certain day' ordered by the date and limit 1. Quote Link to comment https://forums.phpfreaks.com/topic/54704-distinct-first-column-the-rest-not/#findComment-270562 Share on other sites More sharing options...
Illusion Posted June 8, 2007 Share Posted June 8, 2007 select MAX(date_stamp),page, hits from log where date='give-date' I am not sure of it, if it doesn't work try using concatenating date_stamp with a integer or a string and use MAX(). Quote Link to comment https://forums.phpfreaks.com/topic/54704-distinct-first-column-the-rest-not/#findComment-270672 Share on other sites More sharing options...
matchoo Posted June 8, 2007 Author Share Posted June 8, 2007 Can't do that because it's for multiple days. To clarify. I want the last entered hit count per day, for each day. Not for one day... a list of days. Quote Link to comment https://forums.phpfreaks.com/topic/54704-distinct-first-column-the-rest-not/#findComment-270800 Share on other sites More sharing options...
Illusion Posted June 8, 2007 Share Posted June 8, 2007 elect MAX(date_stamp),page, hits from log where date=ALL (select DISTINCT date from log) Quote Link to comment https://forums.phpfreaks.com/topic/54704-distinct-first-column-the-rest-not/#findComment-270871 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.