T

0

Please login or register to vote for this query.

(click on this box to dismiss)

Science Fiction and Fantasy

Q&A for science fiction and fantasy enthusiasts

CREATE TABLE #yt
([data_name] varchar(50), [data_value] varchar(50), [rowNumberId] int)
;
    
INSERT INTO #yt
    ([data_value], [data_name], [rowNumberId])
VALUES
    ('Zero', 'DisasterCounty', 0),
    ('Conecuh', 'DisasterCounty', 1),
    ('Test', 'DisasterCounty', 2),
    ('test', 'DisasterCounty', 3),
    ('9/1/2021', 'DisasterDate', 0),
    ('9/1/2021', 'DisasterDate', 1),
    ('9/2/2021', 'DisasterDate', 2),
    ('9/2/2021', 'DisasterDate', 3),
    ('9/16/2021', 'DisasterEndDate', 0),
    ('Alabama', 'DisasterState', 0),
    ('Alabama', 'DisasterState', 1),
    ('Alaska', 'DisasterState', 2),
    ('California', 'DisasterState', 3)
;


select *
from 
(
  select data_name, data_value, rowNumberId
  from #yt
) src
pivot
(
  sum(rowNumberId)
  for data_name in ([DisasterState], [DisasterCounty], [DisasterDate], [DisasterEndDate])
) piv;

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results