About 400,000 results
Open links in new tab
  1. How do I do multiple CASE WHEN conditions using SQL Server 2008?

    How do I do multiple CASE WHEN conditions using SQL Server 2008? Asked 12 years, 11 months ago Modified 3 years, 5 months ago Viewed 1.7m times

  2. Efficient way to handle multiple CASE statements in SELECT

    Oct 20, 2017 · In any case, with serial queries we can't expect a better result than 0.7 seconds. That's our baseline. The most efficient way to write this query is without joins at all. The key is that the …

  3. sql server - Case with multiple conditions - Database Administrators ...

    Nov 12, 2014 · There are two types of CASE statement, SIMPLE and SEARCHED. You cannot evaluate multiple expressions in a Simple case expression, which is what you were attempting to do.

  4. case statement in SQL, how to return multiple variables?

    Dec 2, 2011 · Depending on your use case, instead of using a case statement, you can use the union of multiple select statements, one for each condition. My goal when I found this question was to select …

  5. Best way to do nested case statement logic in SQL Server

    I'm writing an SQL Query, where a few of the columns returned need to be calculated depending on quite a lot of conditions. I'm currently using nested case statements, but its getting messy. Is th...

  6. sql server - Nested case statements vs multiple criteria case ...

    May 31, 2019 · Had an interesting discussion with a colleague today over optimizing case statements and whether it's better to leave a case statement which has overlapping criteria as individual when …

  7. SQL CASE WHEN with multiple AND and OR - Stack Overflow

    Aug 22, 2018 · Can you please tell me if SQL code below makes sense. I am using multiple ANDs and OR in CASE WHEN. Thanks for your help! SELECT id, period, CASE WHEN state = 'group8' AND …

  8. How can I SELECT multiple columns within a CASE WHEN on SQL …

    Nov 22, 2016 · This uses a delimiter '%' to split the merged columns. You can write your own split function depending on your needs (e.g. for handling null records or using complex delimiter for …

  9. How to get multiple columns in a single SQL CASE statement?

    Oct 9, 2016 · 24 I'm trying to get multiple columns (insuredcode, insuredname in this case) from a single CASE statement. The following query has been tried but it concatenates both insuredcode and …

  10. sql - Multiple CASEs in WHERE Clause with ELSE - Stack Overflow

    May 13, 2014 · Of course, you can use any values you want, you don't need to be evaluating a single column in the condition. Edit: I have created an example using your case statement. It has a second …