[Solved] SQL group data based on a column and pivot rows to (unknown) columns [duplicate]

A straight-up PIVOT in concert row_number() with should do the trick Select * From ( Select ID = fd_Interpretation ,Item = concat(‘Word’,row_number() over (partition by fd_Interpretation order by fd_Word) ) ,Value = fd_Word From YourTable ) src Pivot ( max( Value ) for Item in ([Word1],[Word2],[Word3],[Word4],[Word5],[Word6],[Word7],[Word8]) ) pvt 2 solved SQL group data based on … Read more

[Solved] How do I convert a SQL server timestamp to an epoch timestamp? [duplicate]

You can do it using DATEDIFF function like below : select DATEDIFF(s, ‘1970-01-01 00:00:00’, ‘2017-11-20 23:12:02.000’) as EpochTimeStamp Output : EpochTimeStamp ————– 1511219522 You know already how can we get back the original date : SELECT DATEADD(ss, 1511219522, ‘19700101’) as OriginalDate OriginalDate ———————– 2017-11-20 23:12:02.000 solved How do I convert a SQL server timestamp to … Read more

[Solved] SQl CASE Statement

— ok, Was a date format issue. i used a European Date Format(dd-mm-yyyy) in my query but the system i use takes USA date Format(mm-dd-yyyy) so my query failed. ** Solution ** Select Cast(Case When EventDate <=’01/01/2016′ then ‘PreSeason’ When EventDate >=’12/31/2016′ then ‘PostSeason’ Else ‘Season’ End As Varchar(25)) as Season, EventName From tblEvent Thanks … Read more