I want to group by a table by some columns and show values of other column.in SQL v.2017 I can do that with string_agg function. but my SQL version is 2012.How can I do that...
create table dbo.TaskPeriods
(
[id] [int] NULL,
[startDate] [datetime] NULL,
[endDate] [datetime] NULL
)
-------------------------------
insert into test.dbo.TaskPeriods values(1,'2018-07-24 00:00:00.000','2018-07-24 10:00:00.000')
insert into test.dbo.TaskPeriods values(2,'2018-07-24 00:00:00.000','2018-07-24 10:00:00.000')
insert into test.dbo.TaskPeriods values(3,'2018-07-24 08:00:00.000','2018-07-24 12:00:00.000')
--------------------------------------------------------
select id,startDate,endDate from test.dbo.TaskPeriods
--------------------------------------------------------
select
min (startDate)
,max (endDate)
--,string_agg(id,',') //How to Do this Without string_agg Function
FROM test.dbo.TaskPeriods
group by startDate,endDate
Is there any way to concat one particular column against another group of columns in SQL Server 12.0?