Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with cte as
- (
- select
- case
- when cast(Time_In as time) >'12:00:00' and cast(Time_In as time) <='15:00:00' and Visit_Date = cast(GETDATE() as date)then 'Session 2'
- when cast(Time_In as time) >'3:00:00' and cast(Time_In as time)<= '6:00:00' and Visit_Date = cast(GETDATE() as date) then 'Session 3'
- else 'Session 1'
- end session
- /*course*/
- from Lab_Visits2
- ), ctecnt as (
- select session,/* course,*/ count(*) cnt
- from cte
- group by session /*course*/
- )
- select session, /*course,*/ (cnt)
- from (
- select session, /*course,*/ cnt, row_number() over (order by cnt desc) rn
- from ctecnt
- ) t
- where rn = 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement