Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I understand that QlikView does not like MS SQL CASE statements so I am trying to work around this. It will get more complex but I have to start getting away from the SQL way for this. I basically want to do a select like this:
SLELECT something1, something2, ...., UseRate = CASE WHEN [UKURS] = 0 THEN 1
ELSE [UKURS]
END
This will turn all 0s to 1s....what I really want to do next is look up, in another table, an actual rate based on a different field, like a subselect.... SELECT Rate from rateTable WHERE Country = 'UK' AND Month = 4 and Year = 2015.....but I must learn to walk before I can run....
Thanks for any help,
Dave
David Gilligan wrote:
I understand that QlikView does not like MS SQL CASE statements so I am trying to work around this.
I've never had a problem with CASE statements in SQL SELECT. Everything after the "SQL" is passed directly to the DBMS and is not processed by QV.
CASE
WHEN condition_1 THEN result_1
WHEN condition_2 THEN result_2
...
WHEN condition_n THEN result_n
ELSE result
END
try this
Vikas
David Gilligan wrote:
I understand that QlikView does not like MS SQL CASE statements so I am trying to work around this.
I've never had a problem with CASE statements in SQL SELECT. Everything after the "SQL" is passed directly to the DBMS and is not processed by QV.
Sorry Vikas, maybe I am not clear or I misunderstand you. Can I use a CASE in SQL in QlikView...it appears to throw an error when it hits a case in a sql block...my code works perfectly in SQL Management Studio but dies when I bring it into QlikView.
That is what I thought too....hopefully I just missed something when I copied...let me give another try but it takes a while before I will know, it is a big load but lockally only runs 1 time per day.
Did you have a SQL before the SELECT?
To Test the SQL statement, but a TOP clause for testing
SQL SELECT TOP 1000 ......
Must have meen a typing mistake as it does work and the article that stated that "CASE" does not work when loading tables, actually refers to using a CASE statement in a LOAD not SQL created tables. This is good news for me. Thanks for the responses.