About 3,550,000 results
Open links in new tab
  1. 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 …

  2. sql server - SQL select from a select query - Stack Overflow

    I want to do a select request that perform a first select and then use that selection to perform a second select. I made a 1st version using a temp table but I would like to know - is there is a wa...

  3. What does SQL Select symbol || mean? - Stack Overflow

    Oct 14, 2017 · Microsoft SQL Server is one of the exceptions: it doesn't support ||, and requires +.

  4. SQL "select where not in subquery" returns no results

    Sep 10, 2009 · The long answer (From T-SQL Fundamentals, Third edition, by Itzik Ben-Gan) This is an example: Imagine there is a order with a NULL orderid inside Sales.Orders table, so the subquery …

  5. Using If else in SQL Select statement - Stack Overflow

    Nov 23, 2012 · I have a select statement which will return 2 columns. ID | IDParent Then in my program I have to test if IDParent is < 1 then use ID ELSE use IDParent Is there a way to use an If Else like

  6. SQL - Select first 10 rows only? - Stack Overflow

    Dec 12, 2009 · How do I select only the first 10 results of a query? I would like to display only the first 10 results from the following query: SELECT a.names, COUNT(b.post_title) AS num FROM

  7. sql - Exclude a column using SELECT * [except columnA] FROM tableA ...

    We all know that to select all columns from a table, we can use SELECT * FROM tableA Is there a way to exclude column(s) from a table without specifying all the columns? SELECT * [except columnA]...

  8. sql - DISTINCT for only one column - Stack Overflow

    Feb 19, 2017 · SELECT ID, Email, ProductName, ProductModel FROM Products How can I modify it so that it returns no duplicate Emails? In other words, when several rows contain the same email, I want …

  9. sql - Select first row in each GROUP BY group? - Stack Overflow

    Sep 27, 2010 · I'd like to select the first row of each set of rows grouped with a GROUP BY. Specifically, if I've got a purchases table that looks like this: SELECT * FROM purchases; My Output: id customer …

  10. sql server - SQL MAX of multiple columns? - Stack Overflow

    Mar 8, 2012 · How do you return 1 value per row of the max of several columns: TableName [Number, Date1, Date2, Date3, Cost] I need to return something like this: [Number, Most_Recent_Date, Cost] …