SQL query to add a second node

Viewed 26

I have this code and it works.

SELECT distinct node, 
CASE WHEN node = 'AAA' THEN 'YYY' 
ELSE node_group END node_group,
CASE WHEN scope ='DE' ELSE scope END scope

However I *would like to add another node 'AAA' next to 'BBB'. How do I added to the code.

I have tried with AND and a comma but it doesn't work:

SELECT distinct node, 
CASE WHEN node = 'AAA' AND 'BBB' THEN 'YYY' 
ELSE node_group END node_group,
CASE WHEN scope ='DE' ELSE scope END scope

Any ideas?

1 Answers

It must be like this

SELECT distinct node, 
CASE WHEN node = 'AAA' OR node = 'BBB' THEN 'YYY' 
ELSE node_group END node_group,
CASE WHEN scope ='DE' THEN 1 ELSE scope END scope

or

SELECT distinct node, 
CASE WHEN node IN ('AAA', 'BBB') THEN 'YYY' 
ELSE node_group END node_group,
CASE WHEN scope ='DE' THEN 1 ELSE scope END scope
Related