I have a table
as follows :
ID HC Week
1 2 1
1 0 2
2 14 1
2 12 2
3 9 1
3 0 2
the data is generated by (what I believe to be) a complex query.
now what I'm trying to do is wrap this in a sub query and only return the max HC
column by ID with its corresponding week.
the best I can do is wrap a max function and group it by ID and pass in theMAX(HC)
function as such
SELECT
max(HC),
ID
from (sub query)
group by
ID
this gets me very close, but I also want the corresponding week when I pass this in it returns the above table with every key.
SELECT
max(HC),
ID,
Week
from (sub query)
group by
ID,
Week
what I'm after is the following :
ID HC Week
1 2 1
2 14 1
3 9 1
is anyone able to guide me ?