Hi,
I have a SQL query that looks like this:
, CASE WHEN object 1 LIKE '%first%'
OR object 1 LIKE '%second%'
OR object 2 LIKE '%first%'
OR object 2 LIKE '%second%'
THEN object 3
END AS [column 1]
, CASE WHEN object 1 LIKE '%first%'
OR object 1 LIKE '%second%'
OR object 2 LIKE '%first%'
OR object 2 LIKE '%second%'
THEN object 4
END AS [column 2]
The whole query is quite long and so it runs quite slowly - I think it's because it goes through the whole of the database for each of the CASE statements? (there's 12 of them)
Is there a way of embedding the CASE statements or something?
What I'm trying to do is:
IF object 1 LIKE (list of options1) OR object 2 LIKE (list of options2)
THEN object 3 AS Column 1
AND object 4 AS Column 2
...
any ideas?
Thanks!
I have a SQL query that looks like this:
, CASE WHEN object 1 LIKE '%first%'
OR object 1 LIKE '%second%'
OR object 2 LIKE '%first%'
OR object 2 LIKE '%second%'
THEN object 3
END AS [column 1]
, CASE WHEN object 1 LIKE '%first%'
OR object 1 LIKE '%second%'
OR object 2 LIKE '%first%'
OR object 2 LIKE '%second%'
THEN object 4
END AS [column 2]
The whole query is quite long and so it runs quite slowly - I think it's because it goes through the whole of the database for each of the CASE statements? (there's 12 of them)
Is there a way of embedding the CASE statements or something?
What I'm trying to do is:
IF object 1 LIKE (list of options1) OR object 2 LIKE (list of options2)
THEN object 3 AS Column 1
AND object 4 AS Column 2
...
any ideas?
Thanks!
Comment