rank.rao.7.n
BAN USERselect a.cust_id,a.cust_name, count(b.order_id) as total
From Customer as a left join [Order] as b
on a.cust_id=b.cust_id
group by a.cust_id,a.cust_name
having count(b.order_id)>=1
order by a.cust_id
select * From (select b.obj_id,b.obj_name,c.Att_name,a.att_value
From ObjectAttributrMapping as a join Object as b on a.obj_id = b.obj_id
join Attribute as c on a.att_id =c.Att_id) as t
pivot( max(att_value) for Att_name in (color,height,length,width) ) a
order by obj_id
create table Input
(userid int,
Logintime datetime)
create table Output
(userid int,
Logintime datetime,
SessionId int)
select getdate()
insert into Input values(1,'2017-02-05 09:00:00.000')
insert into Input values(2,'2017-02-05 09:10:00.000')
insert into Input values(1,'2017-02-05 09:25:00.000')
insert into Input values(30,'2017-02-05 12:34:00.000')
insert into Input values(23,'2017-02-05 15:09:00.000')
declare @userid int,@Logintime datetime
declare Rank_Cursor Cursor For
select userid,Logintime from Input
open Rank_Cursor
fetch next from Rank_Cursor into @userid,@logintime
while @@FETCH_STATUS=0
begin
if exists (select 1 from Output where userid=@userid and Logintime>=dateadd(mi,-30,@logintime) and Logintime<@logintime)
insert into Output
select @userid,@logintime,isnull(max(SessionId),1)
from Output
where userid=@userid and Logintime>=dateadd(mi,-30,@logintime) and Logintime<@logintime
else
insert into Output
select @userid,@logintime,isnull(max(SessionId),0)+1
from Output
fetch next from Rank_Cursor into @userid,@logintime
end
close Rank_Cursor
deallocate Rank_Cursor
select * From output
select count(0) from (
select Row_Number() over (partition by Name order by date desc) as RowNo,*
from rsvp
) T
where RowNo=1 and Descision='Y'
- rank.rao.7.n February 05, 2017