NehaaVishwa
BAN USERselect * from
(
select o.Obj_id,Obj_name,Att_name,Att_value from Object1 o cross join Attribute a
left outer join ObjectAttributeMapping oa
on o.Obj_id=oa.Obj_id and a.Att_id=oa.Att_id
) A
PIVOT
(
Min(Att_value)
FOR
Att_name
IN( [color],[height],[length],[width])
)PivotTable
order by Obj_id
#Assuming table structure as below:
create table Flight
(
FlightNo int
, DepartTime datetime
)
Go
select getdate()
insert Flight
values (1, '2017-01-23 20:53:41.733')
,(2, '2017-01-23 21:53:41.733')
,(3, '2017-01-23 23:53:41.733')
,(4, '2017-01-24 21:53:41.733')
,(2, '2017-01-22 21:53:41.733')
select top(1) FlightNo from(
select *, datediff(minute, getdate(),DepartTime) time
from Flight)A
where sign(time)=1
order by time
Go
; with e as
(
select *, 50 as a from(
select *, row_number() over(partition by UID order by LoginTime) rr from UserSession
)
A where rr=1
union all
select A.*,datediff(minute, e.LoginTime, A.LoginTime) --dateadd(minute,30,e.LoginTime)
from(
select *, row_number() over(partition by UID order by LoginTime) rr from UserSession
)
A inner join e on e.UID=A.UID and e.rr+1=A.rr --where datediff(minute, e.LoginTime, A.LoginTime)>=30 --A.LoginTime>=dateadd(minute,30,e.LoginTime)
)
select UID, LoginTime, row_number() over(partition by UID order by UID) UserSession
from e where a>=30
Repjacksonbetty625, Accountant at 247quickbookshelp
My work is specialized help, regardless of whether on the telephone, face to face, or distantly, identified with PC frameworks ...
- NehaaVishwa January 25, 2017