查询后值不为一,有多条怎么办

wxl84911 wxl84911 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
declare @userid int
select @userid=24
--考勤记录,注意过滤日期
select u2.fnumber as 工号,u3.fname as 部门,u2.fname as 姓名,u4.fname 职务,工种=u5.fname,u1.*
from t_workrecord u1
left join t_emp u2 on u1.fempid=u2.fempid
left join t_dept u3 on u2.fdeptid=u3.fdeptid
left join t_position u4 on u2.fpositionid=u4.fpositionid
left join t_duty u5 on u2.fdutyid=u5.fdutyid
where
((select fisright from t_user where fuserid=@userid)=0 or charindex(','+cast(@userid as varchar(100))+',',u2.frightdata)>0)
and u1.fbegindate between '2010-09-23 00:00:01' and '2010-09-23 23:59:59' order by u3.部门--dateadd(day,-1,getdate()) and getdate()


查询后,有相同工号的多条记录(其他字段值不一样),想要让工号唯一显示,加上DISTINCT 也不行,怎么办?
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
wxl84911
疑难问题 22,298 成员 121,727 内容