13,150,163 members (81,601 online)
Rate this:
See more:
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
Posted 18-Feb-13 17:11pm
richcb 19-Feb-13 15:39pm

You have been a memeber for almost 9 years and you are asking your first question today. What is up with that?

Excuse me, where did you find a question?!
—SA
richcb 9-Apr-13 9:40am

No question indeed, should have said first thread.

Rate this:

Solution 1

Hi,

try this query,
`SELECT DISTINCT StaffNO, COALESCE(Cast(DateTime As VRACHAR(50)) + '-', '') as 'Time' FROM TableName GROUP BY StaffNo`

hope it helps
Rate this:

Solution 4

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)```

Top Experts
Last 24hrsThis month
 OriginalGriff 230 Richard MacCutchan 123 ppolymorphe 100 CPallini 85 Kornfeld Eliyahu Peter 70
 OriginalGriff 6,438 Graeme_Grant 5,111 ppolymorphe 2,114 CPallini 1,940 Jochen Arndt 1,904