About 197,000 results
Open links in new tab
  1. SQL Case Expression Syntax? - Stack Overflow

    Aug 7, 2008 · case expression is the correct term as they evaluate to a scalar value (also. in SQL a statement is terminated by the "statement terminator" which is the semi-colon).

  2. How do I perform an IF...THEN in an SQL SELECT?

    Sep 15, 2008 · The CASE statement is the closest to IF in SQL and is supported on all versions of SQL Server.

  3. sql - Case in Select Statement - Stack Overflow

    Jan 7, 2013 · I have an SQL statement that has a CASE from SELECT and I just can't get it right. Can you guys show me an example of CASE where the cases are the conditions and the results are from …

  4. SQL Switch/Case in 'where' clause - Stack Overflow

    Oct 16, 2008 · sql switch-statement case edited Jun 14, 2019 at 18:47 Peter Mortensen 31.4k 22 110 134

  5. How do I use T-SQL's Case/When? - Stack Overflow

    Jul 27, 2010 · The original query has multiple SELECT statements, so MS SQL server is expecting subqueries. It an easy mistake to make if you're used to some programming languages that use …

  6. sql - using case statement in a where clause - Stack Overflow

    Dec 2, 2020 · SQL Server refers to these as Simple vs Searched but refers to all of it as a CASE Expression. Therefore a CASE Expression can either be a Simple or a Searched CASE that can be …

  7. 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...

  8. CASE .. WHEN expression in Oracle SQL - Stack Overflow

    SELECT status, CASE status WHEN 'a1' THEN 'Active' WHEN 'a2' THEN 'Active' WHEN 'a3' THEN 'Active' WHEN 'i' THEN 'Inactive' WHEN 't' THEN 'Terminated' END AS StatusText FROM stage.tst …

  9. SQL use CASE statement in WHERE IN clause - Stack Overflow

    Oct 9, 2013 · SQL use CASE statement in WHERE IN clause Asked 12 years, 2 months ago Modified 5 years, 1 month ago Viewed 189k times

  10. SQL GROUP BY CASE statement with aggregate function

    CASE WHEN col1 > col2 THEN SUM(col3*col4) ELSE 0 END AS some_product And I would like to put it in my GROUP BY clause, but this seems to cause problems because there is an aggregate …