0
Good afternoon, I need to unify some data, when I bring this so:
id 2017 2017-LOJA 2018 2018-LOJA
1 n n s s
1 s s n n
Would like so:
id 2017 2017-LOJA 2018 2018-LOJA
1 s s s s
consultation I made:
SELECT id,
CASE WHEN YEAR(DATA) = 2017 THEN 'S' END AS '2017',
CASE WHEN YEAR(DATA) = 2017 AND ORIGEM = 'LOJA' THEN 'S' END AS '2017 - LOJA',
CASE WHEN YEAR(DATA) = 2018 THEN 'S' END AS '2018',
CASE WHEN YEAR(DATA) = 2018 AND ORIGEM = 'LOJA' THEN 'S' END AS '2018 - LOJA'
FROM table
WHERE ORIGEM = 'LOJA'