SQL Server 2008 R2: Display Date in Comma Separated Column
I have the following table with two fields:
create table test_t
(
cola varchar(10),
coldate date
);
Inserting some records:
insert into test_t values('A','1-1-2010'),
('A','2-1-2010'),
('A','4-1-2010'),
('B','6-1-2010'),
('B','8-1-2010'),
('C','10-1-2010'),
('D','11-1-2010');
Note . Now I want to show the values cola
that refer to 2 - 3 days. And want to show this day in a comma separated column as shown below in the expected ouptput.
Expected Output :
cola Dates_Day
------------------
A 1,2,4
B 6,8
+3
source to share