Hello,
need help for query giving me the LAE_PV max temperature value for everyday where the system has been worked. The table is like this:
So, the output must be something like this:
t_stamp LAE_PV
2022-03-20 15.6
2022-03-27 16.5
etc…
I tried this query:
but obviously it is not what I am looking for
SQL SERVER 2016
Thank you!
Your issue is the the group by clause, you need to group by day not by t_stamp since the t_stamp contains year, month, day, hours, minutes, seconds, … use
group by datepart(day, t_stamp), lae_pv
EDIT As noted below, it should be grouped by the date, not day. Not sure how I missed that
1 Like
You’ll need to format t_stamp into just the date:
SELECT CAST(t_stamp AS DATE) AS t_stamp, max(lae_pv)
FROM temp
GROUP BY CAST(t_stamp AS DATE)
ORDER BY CAST(t_stamp AS DATE)
1 Like
Thank you for your replies, dkhayes117 and JordanCClark!
It worked!