12,403,811 members (69,925 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 353 Richard MacCutchan 217 Karthik Bangalore 210 Suvendu Shekhar Giri 185 0x01AA 100
 OriginalGriff 7,386 Karthik Bangalore 3,127 ppolymorphe 3,100 Richard MacCutchan 2,342 F-ES Sitecore 2,262