select [SName],MAX([DateTime]) as Dates
from table
where [DateTime] between @MNT1 and @MXT1 and [DateTime] <=@MXT1
group by[SName] ,CONVERT(Date,[DateTime])
order by [SName],CONVERT(Date,[DateTime])
I'd like to somehow calculate average only for the max timestamp per day for each column.
@mnt1 and 2 are set as start date and end date for report
ID SERVERNAME COL2 COL3 COLN DATETIME
1 A 1.1 1.5 2022-08-01 23:50:13.0000000
2 A 1.1 1.6 2022-08-01 23:55:13.55530000
3 B 1.7 2 2022-08-01 23:50:13.7530000
4 C 3.4 2 2022-08-02 23:50:13.7530000
5 C 1.4 5 2022-08-08 23:50:13.7530000
I'm trying to calculate average based on the last value logged per day for each server eg. server A for month of august will have timestamps throughout the day till server is shut down at midnight ,for A il have last recorded date timestamp for the 1st of august through to end of august now I need to capture those and calculate monthly average soley based on those timestamps and so on foe each server