About 30,500 results
Open links in new tab
  1. 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 …

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

  3. mysql - SELECT CASE WHEN THEN (SELECT) - Stack Overflow

    Feb 15, 2013 · You will be running that select for each row that is returned. This is a really expensive operation. Rather use joins. It is much more readable and the performance is much better. In your …

  4. sql - How to write a select inside case statement - Stack Overflow

    2 I have a stored procedure that contains a case statement inside a select statement.

  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. Using CASE to select a field in SQL? - Stack Overflow

    Nov 10, 2010 · Based on if one field in the database is equal to something, I want to select the value of another field. I was thinking that I could use CASE THEN but I can't get it to return the value of a field.

  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. SQL Switch/Case in 'where' clause - Stack Overflow

    Oct 16, 2008 · In SQL the rest of the expression does get evaluated in the OR syntax. Try this (it wouldn't let me include the @ symbol - you will have to correct it if you want to test it): declare var …

  9. sql - How do I execute different SELECT statements based on a CASE ...

    Jul 2, 2010 · I am facing a problem in executing queries with CASE statement. Based on my condition,(for eg. length), I want to execute different SQL statement. Problematic sample query is as …

  10. How can I SELECT multiple columns within a CASE WHEN on SQL Server?

    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 …