About 43,600 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. 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.

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

  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. How do I do multiple CASE WHEN conditions using SQL Server 2008?

    SELECT Url='', p.ArtNo, p.[Description], p.Specification, CASE WHEN 1 = 1 or 1 = 1 THEN 1 ELSE 0 END as Qty, p.NetPrice, [Status] = 0 FROM Product p (NOLOCK) However, what I want to do is use …

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

    Oct 25, 2012 · CASE WHEN ProductLine like '[Rr]' THEN 'Road' WHEN ProductLine like '[Mm]' THEN 'Mountain' Note that in SQL, string comparison is case-insensitive by default. You can alter the …

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

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

  10. sql - Can I use CASE statement in a JOIN condition ... - Stack Overflow

    Apr 21, 2012 · 62 Instead, you simply JOIN to both tables, and in your SELECT clause, return data from the one that matches: I suggest you to go through this link Conditional Joins in SQL Server and T …