TABLE: pages
pageId | name
1 | Home
2 | About Us
3 | Contact Us
接下来我有存储的统计信息:
TABLE: hits
hid | created | assignId
01 | 1000000001 | 1
02 | 1000000002 | 1
03 | 1000000003 | 3
基本上,“主页”被打开了两次,“关于我们”从未被打开,而“联系我们”被打开了一次。还请注意,“联系我们”是最近访问的。
我需要一个返回此结果的查询:
pageId | name | lastAccessDate
1 | Home | 1000000002 --> NB: Notice that it takes the higher one
2 | About Us | null
3 | Contact Us | 1000000003
有人知道怎么做吗?
ORDER BY created DESC GROUP BY assignId
- Piskvor left the building