Sqlserver在出勤,时间,日期方面存在疑问 [英] Sqlserver Doubt in Attendance, Time, Date
问题描述
输入:
我有桌子
员工没有约会时间
12333 12-02-2013 09.30
12333 12-02-2013 17.30
13245 12-02-2013 09.15
13245 12-02-2013 10.10
13245 12-02-2013 17.35
14555 12-02-2013 09.10
14555 12-02-2013 10.40
14555 12-02-2013 11.45
14555 12-02-2013 17.30
输出:
12333 12-02-2013 09.30-17.30
13245 12-02-2013 09.15-10.10,17.35
14555 12-02-2013 09.10-10.40,11.45-17.30
谢谢和问候,
Nirmal.M
Input :
I am having the table
StaffNo Date Time
12333 12-02-2013 09.30
12333 12-02-2013 17.30
13245 12-02-2013 09.15
13245 12-02-2013 10.10
13245 12-02-2013 17.35
14555 12-02-2013 09.10
14555 12-02-2013 10.40
14555 12-02-2013 11.45
14555 12-02-2013 17.30
Output :
12333 12-02-2013 09.30-17.30
13245 12-02-2013 09.15-10.10,17.35
14555 12-02-2013 09.10-10.40,11.45-17.30
Thanks & Regards,
Nirmal.M
推荐答案
试试这个查询,
Hi,
try this query,
SELECT DISTINCT StaffNO, COALESCE(Cast(DateTime As VRACHAR(50)) + '-', '') as 'Time' FROM TableName GROUP BY StaffNo
希望有帮助
hope it helps
看下面的查询,
可能有帮助... < br $> b $ b
see the below query,
might it helps...
select a.StaffNo,a.Date, SUBSTRING(b.alltime ,1, LEN(b.alltime ) - 1) from
(select distinct StaffNo, Date from tablename) A cross apply
(select time +',' from tablename where id=a.StaffNo and name=a.Date for xml path('')) B (alltime)
这篇关于Sqlserver在出勤,时间,日期方面存在疑问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!