Hello ... I hope someone can help me on this.
I have a table that lists customers and the books they have purchased tne the language they purchased that book in.
I have three requirements and what I thought was an easy task is turning out not to be so easy. Here is the way I originally thought to tackle this.
Create three columns: English, Spanish, Portuguese.
1. If the language specification is set to English or is null, then set column English to 1.
2. If language specification is set to Spanish, then set column Spanish to 1.
3. If lanuage specification is set to Portuguese or Spanish, then set column Portuguese to 1.
This is the code I used to handle this but this is not working the way I expected.
Would anyone have any suggestions?
Thanks in advance!
I have a table that lists customers and the books they have purchased tne the language they purchased that book in.
I have three requirements and what I thought was an easy task is turning out not to be so easy. Here is the way I originally thought to tackle this.
Create three columns: English, Spanish, Portuguese.
1. If the language specification is set to English or is null, then set column English to 1.
2. If language specification is set to Spanish, then set column Spanish to 1.
3. If lanuage specification is set to Portuguese or Spanish, then set column Portuguese to 1.
This is the code I used to handle this but this is not working the way I expected.
Code:
SELECT ...,
'1' AS ENGLISH, '0' AS SPANISH, '0' AS PORTUGUESE
FROM TABLE
WHERE LANGUAGE IN ('EN','NULL')
UNION
SELECT ...,
'0' AS ENGLISH, '1' AS SPANISH, '0' AS PORTUGUESE
FROM TABLE
WHERE LANGUAGE = 'SP'
UNION
SELECT ...,
'0' AS ENGLISH, '0' AS SPANISH, '1' AS PORTUGUESE
FROM TABLE
WHERE LANGUAGE IN ('SP','PO');
Would anyone have any suggestions?
Thanks in advance!