Sorry for weird title its hard for me to explain what i need but i will do my best,
My table BehaviorHidraulics contains these columns: [id],[siteIDDatagate],[datetime],[value],[channelnum],[channeltype], now i need to find the lowest value of [value] in a certain date and i've managed to do so with this query:
select min(value) as minvalue, siteIDDatagate, channeltype, channelnum, datetime
from BehaviorHidraulic where channelnum = '1' and datetime
between '2021-10-10 00:00:00' and '2021-10-10 23:59:59'
group by siteIDDatagate, channeltype, channelnum, datetime order by siteIDDatagate, minvalue ASC
now this returns something like this:
minvalue siteIDDatagate
26 _site_1003
26,39 _site_1003
26,5 _site_1003
17,20 _site_303
17,600 _site_303
58,200 _site_304
58,599 _site_304
and this is good but i need to ditch every result under the first row for every site so it could look like this:
minvalue siteIDDatagate
26 _site_1003
17,20 _site_303
58,200 _site_304
i think i need to use the lag function but im not very good with SQL so please any help is greatly appreciated