Hello,
I'm not sure how to approach this SQL statement so please advise, even if its just a pointer to something I can read up on
I have a table, such as the following
ID OVER60 OVER80
1 N N
2 Y N
3 Y Y
The IDs are unique, what I need to do is to create a SELECT
statement that will return the ID, and then either 'Over 60' or 'Over 80', such as :
ID AGE
2 Over 60
3 Over 80
What I need to avoid, is duplicates, meaning if someone is 'Over 80', then there is no need to display 'Over 60' aswel, since its pretty obvious
I've looked at UNION
to see if that would help, and this is what I have so far :
SELECT
a.id,
'OVER60' as AGE
FROM
MY_TABLE a
WHERE
a.OVER_60 != 'N'
UNION
SELECT
a.id,
'OVER80' as AGE
FROM
MY_TABLE a
WHERE
a.OVER_80 != 'N'
;
What are my options? would using a MINUS
help me here?
Thanks