i am looking to get the primary key from a group by.
What i am looking for is to select all the Maximum and Minimum temperature for a day and get the primary key for that entry.
select Cast(DateTime as date) AS 'Date', MAX(Temperature) AS 'Max Temperature'
from [Testing].[dbo].[Reading]
GROUP by Cast(DateTime as date)
ORDER by Cast(DateTime as date)
This will find me the maximum temperature for each day however due to the group by i am unable to get the primary key for that entry that is the highest for that day. Any Help?