34,593
社区成员
发帖
与我相关
我的任务
分享
create proc sp_test
@userId int
as
select
t.*
from
表 t
where
not exists(select 1 from 表 where 用户id=t.用户id and 任职开始时间>t.任职开始时间)
And(t.userid=@userid or isnull(@userid,'')='')
select
*
from
tb t
where
任职开始时间=(select max(任职开始时间) from tb where 用户id=t.用户id )
select
*
from
tb t
where
任职开始时间=(select max(任职开始时间) from t where 用户id=t.用户id )
select
t.*
from
表 t
where
任职开始时间=(select MAX(任职开始时间) from 表 where 用户id=t.用户id )
select
t.*
from
表 t
where
not exists(select 1 from 表 where 用户id=t.用户id and 任职开始时间>t.任职开始时间)