GreenWizard
Board Regular
- Joined
- Dec 8, 2013
- Messages
- 106
Based on the table below how can I write a SQL Query to Select the Date, Color, AND Corresponding Number (Based on the rules below)
EXAMPLE
<tbody>
</tbody>
IF Color = Red
Then Query Column3 = Number2
If Color = Blue
Then Query Column3 = Number1
If Color = Brown
Then Query Column3 = Number3
If Color = <Anything Other Color>
Then Query Column3 = N/A
EXAMPLE OF DESIRED SQL OUTPUT
<tbody>
</tbody>
SQL QUERY CODE: ???
THANKS SO MUCH!!!!!
EXAMPLE
Date | Color | Number1 | Number2 | Number3 |
1/1 | Red | 2 | 5 | 9 |
1/2 | Blue | 7 | 5 | 3 |
1/3 | Brown | 6 | 1 | 4 |
<tbody>
</tbody>
IF Color = Red
Then Query Column3 = Number2
If Color = Blue
Then Query Column3 = Number1
If Color = Brown
Then Query Column3 = Number3
If Color = <Anything Other Color>
Then Query Column3 = N/A
EXAMPLE OF DESIRED SQL OUTPUT
Date | Color | Column3 |
1/2 | Blue | 7 |
1/3 | Brown | 4 |
1/4 | Black | N/A |
1/1 | Red | 5 |
<tbody>
</tbody>
SQL QUERY CODE: ???
THANKS SO MUCH!!!!!