Viewing 4 posts - 1 through 4 (of 4 total)
Try this. I get the results that you want, but you should try it in your system to check the performance.
with ct1
as
(
select t.ID,t.Date, case when t.Column1 is ...
July 22, 2016 at 4:54 pm
with Mycte
as
(
select ROW_NUMBER()over(order by id)as c, t.* from ##TEST as t
)
select t1.DT as "startDate", t2.DT as "endDate"from Mycte as t1
left join Mycte as t2
on t1.ID =t2.ID and t1.c=t2.c-1
July 9, 2016 at 3:09 pm
SELECT
COALESCE(
STUFF(
(SELECT ',' + CAST(dbs AS VARCHAR(10)) AS [text()]
FROM #l
ORDER BY dbs
FOR XML PATH(''), TYPE).value('.', 'VARCHAR(MAX)'),
1, 1, ''),
'') AS letters
FROM #l as c;
June 21, 2016 at 8:37 pm
select customerId, window, product, sales,
( Case when count(sales) over(partition by customerid order by customerid) >0 then 1 else 0 end)as class
from #example
May 27, 2016 at 6:57 pm
Viewing 4 posts - 1 through 4 (of 4 total)