About 191,000 results
Open links in new tab
  1. 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. SELECT CAST( CASE WHEN Obsolete = 'N' or InStock = 'Y' THEN 1 ELSE 0 …

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

  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 …

  4. sql - Case statement with 'OR' statement - Stack Overflow

    Oct 25, 2012 · Note that in SQL, string comparison is case-insensitive by default. You can alter the default by setting a case-sensitive database collation, but that's fairly unusual.

  5. SQL Server CASE .. WHEN .. IN statement - Stack Overflow

    May 18, 2011 · On SQL server 2005 I am trying to query this select statement SELECT AlarmEventTransactionTableTable.TxnID, CASE AlarmEventTransactions.DeviceID WHEN …

  6. sql - CASE inside a COALESCE - Stack Overflow

    Sep 14, 2018 · For anyone struggling with this issue, to appropriately write a CASE statement within a COALESCE statement, the code should be revised as follows: COALESCE …

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

  8. CASE (Contains) rather than equal statement - Stack Overflow

    Jun 5, 2012 · Is there a method to use contain rather than equal in case statement? For example, I am checking a database table has an entry lactulose, Lasix (furosemide), oxazepam, …

  9. SQL: How use case and cast in a query? - Stack Overflow

    Aug 23, 2013 · 6 I believe you would want something like INSERT INTO labbd11..movie(title, year) SELECT movies.title, CAST( CASE movies.mvyear WHEN '????' THEN NULL ELSE …

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

    sql switch-statement case edited Jun 14, 2019 at 18:47 Peter Mortensen 31.5k 22 110 134