PK_Test_01

0

Please login or register to vote for this query.

(click on this box to dismiss)

Literature Meta

Q&A about the site for scholars and enthusiasts of literature

CREATE table #yourtable
    ([Id] varchar(12), [Access] varchar(3), [DB1] varchar(1), [DB2] varchar(1), [DC1] varchar(1))
;
    
INSERT INTO #yourtable
    ([Id],[Access], [DB1], [DB2], [DC1])
VALUES
    ('1','DB1', 'Y',null,null),
    ('1','DB2', null,null,null),
    ('1','DC1', null,null,'Y'),
    ('2','DB1', 'Y',null,null),
    ('2','DB1', null,'Y',null),
    ('3','DC1', null,null,'Y')

;

SELECT ACCESS, MAX(DB1), MAX(DB2), MAX(DC1)
FROM #yourtable
GROUP BY ACCESS

Enter Parameters

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