'Fetching only one row even multiple exist

I'm trying to create an SQL query that will fetch only one row, even if multiple exist.

My DB looks like:

Name | Page | Date
John | 2201 | 22.05
John | 2202 | 22.05
John | 2202 | 23.05 

What I want to have from select query is:

John | 2201 | 22.05
John | 2202 | 23.05

So if John visited same page multiple times, I want to store last time he visited that page.

I tried to do it with GROUP BY, but I think there should be another way of doing this?

Thanks in advance for any suggestions :)



Solution 1:[1]

try this

select name,page, max(date) as date
from MyTable
group by name,page

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RegBes