About 55 results
Open links in new tab
  1. sql - can you do an ELSE WHEN on a CASE - Stack Overflow

    Nov 4, 2011 · No, ELSE is a catch-all. In your example, it's not clear why you would want to include a condition in the ELSE clause, since you've already checked the logically opposite condition in the …

  2. SQL Case Expression Syntax? - Stack Overflow

    Aug 7, 2008 · Link: CASE (Transact-SQL) Also note that the ordering of the WHEN statements is important. You can easily write multiple WHEN clauses that overlap, and the first one that matches is …

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

    Sep 15, 2008 · SELECT CASE WHEN Obsolete = 'N' or InStock = 'Y' THEN 1 ELSE 0 END as Saleable, * FROM Product CASE statements can be embedded in other CASE statements and even included …

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

  5. SQL CASE WHEN or IF ELSE IF - Stack Overflow

    Sep 6, 2014 · SQL CASE WHEN or IF ELSE IF Asked 11 years, 4 months ago Modified 6 years, 3 months ago Viewed 83k times

  6. Nested CASE Statement With ELSe (SQL Server) - Stack Overflow

    Feb 26, 2015 · Nested CASE Statement With ELSe (SQL Server) Asked 10 years, 10 months ago Modified 10 years, 10 months ago Viewed 104k times

  7. sql - Case when versus if else statement - Stack Overflow

    Jul 9, 2020 · Firstly case is an expression - not a statement, secondly their use-case is completely different, one modifies the result of a query, one modifies the flow path of executing statements. In …

  8. sql - IF Else in Select Case? - Stack Overflow

    Sep 2, 2017 · Update Tab set Quantity2 = a.Quantity from ( select case when D.Quantity1 > Tab.Quantity2 then D.Quantity1 ------------> (if and else here) else Tab.Quantity3 end as Quantity …

  9. T-SQL CASE Clause: How to specify WHEN NULL - Stack Overflow

    I wrote a T-SQL Statement similar like this (the original one looks different but I want to give an easy example here): SELECT first_name + CASE last_name WHEN null THEN 'Max' ELSE 'Peter' EN...

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

    I would add ELSE status before END so if a new status does creep in you get the base status value rather than a null for STATUSTEXT. I would not default to ELSE 'active' in case a new inactive or …