Hello:
I had a quick question on using the DISTINCT clause in a SELECT query.
I have the following table which stores webpages viewed
table: page_viewed
page_id int unsigned "page id of the page viewed"
user_id int unsigned "user id of the page viewed"
ts timestamp "timestamp of the page view".
Now i need to query the most recently viewed distinct pages and i have
the following data
page_id user_id ts
1 1 2007-03-13 20:40:46
2 1 2007-03-13 20:40:53
2 1 2007-03-13 20:41:01
1 1 2007-03-13 20:41:10
SELECT DISTINCT page_id
FROM page_viewed
WHERE user_id =1
ORDER BY ts DESC
----------------------------------------------------------------
Go Pre
http://www2.localaccess.com/rlalonde/pre.htm
----------------------------------------------------------------
| Thread |
|---|
| • using DISTINCT after the ORDER BY clause has been applied | Yashesh Bhatia | 13 Mar |