Click here to Skip to main content
15,075,626 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,


I am using a query for showing weekly data.but i want to start week from latest entry of date in database.how to do this??

my query is given below:
SQL
select count(MissedLogParam) as MissedLogParam,convert(varchar(12),DATEADD(wk, DATEDIFF(wk,9, Server_DateTime),10),106)
 as 'Server_DateTime'
 from DeviceAlarmLog where Server_DateTime>=DATEADD(dd,-7,Server_DateTime) and IsAbsent=1
 group by DATEADD(wk, DATEDIFF(wk,9, Server_DateTime),10)
 order by DATEADD(wk, DATEDIFF(wk, 9, Server_DateTime),10)
 select count(MissedLogParam)  as 'TotalAlarm' from DeviceAlarmLog
group by DATEADD(wk, DATEDIFF(wk, 9, Server_DateTime),10)
order by DATEADD(wk, DATEDIFF(wk, 9, Server_DateTime),10)
Posted

1 solution

Like this MAX(date) ???
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900