I have this table:
id | day | count
----------------
u tue 1
u wed 4
w wed 5
x mon 5
y mon 5
x tue 2
I want to return the rows with the highest count on each day.
So I want to get this table:
id | day | count
----------------
w wed 5
x mon 5
y mon 5
x tue 2
Here’s my sql, but it’s not giving me the right output:
select id, day, MAX(count)
from Table
group by day
It is giving me:
id | day | count
----------------
w wed 5
y mon 5
x tue 2
you can use a sub-query:
sqlFiddle