Hello,
Im having trouble placing IF and ELSEIF in the right place.
Basically I need IF "A" = 1000 then do this... ELSE IF "A"= 2000 then do this.....
I have to add "IF" before CASE and the ELSEIF to continue with statement.
This is what i have now....
SELECT
*
FROM ( a, b, c, d,
CASE
WHEN .....THEN .....
WHEN......THEN......
END AS xxxxx
from f_all_hist)
WHEN a = '1000' i also have a = 2000 with different WHEN......THEN......
How can i use IF and ELSEIF *inside* the sql statment. I should have only one SELECT stament, not sure if one CASE:
Something like this (This is wrong!)
SELECT
*
FROM (
SELECT a, b, c, d, e,
IF a = '1000' THEN
(CASE
WHEN b BETWEEN 4001 AND 4500
THEN 'D
ELSIF a = '2000'
THEN ( CASE
WHEN b BETWEEN 4001 AND 4500
THEN N
end as ……………..
from ……………)
Thank you
Im having trouble placing IF and ELSEIF in the right place.
Basically I need IF "A" = 1000 then do this... ELSE IF "A"= 2000 then do this.....
I have to add "IF" before CASE and the ELSEIF to continue with statement.
This is what i have now....
SELECT
*
FROM ( a, b, c, d,
CASE
WHEN .....THEN .....
WHEN......THEN......
END AS xxxxx
from f_all_hist)
WHEN a = '1000' i also have a = 2000 with different WHEN......THEN......
How can i use IF and ELSEIF *inside* the sql statment. I should have only one SELECT stament, not sure if one CASE:
Something like this (This is wrong!)
SELECT
*
FROM (
SELECT a, b, c, d, e,
IF a = '1000' THEN
(CASE
WHEN b BETWEEN 4001 AND 4500
THEN 'D
ELSIF a = '2000'
THEN ( CASE
WHEN b BETWEEN 4001 AND 4500
THEN N
end as ……………..
from ……………)
Thank you