About 2,790,000 results
Open links in new tab
  1. How to select unique records by SQL - Stack Overflow

    DISTINCT keyword is supposed to be applied to all the columns in the select query and not just to the column next to which DISTINCT keyword is written. So, basically, it means that every row …

  2. sql - How to use DISTINCT and ORDER BY in same SELECT …

    281 The problem is that the columns used in the ORDER BY aren't specified in the DISTINCT. To do this, you need to use an aggregate function to sort on, and use a GROUP BY to make the …

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

    Feb 19, 2017 · When you use DISTINCT think of it as a distinct row, not column. It will return only rows where the columns do not match exactly the same.

  4. How do I (or can I) SELECT DISTINCT on multiple columns?

    Sep 10, 2008 · 30 The problem with your query is that when using a GROUP BY clause (which you essentially do by using distinct) you can only use columns that you group by or aggregate …

  5. sql - Using DISTINCT and TOP in the same query - Stack Overflow

    I want to use DISTINCT and TOP in the same query. I tried SELECT DISTINCT TOP 10 * FROM TableA but I still have a duplicate personID, so I tought to do: SELECT DISTINCT (personID) …

  6. Using DISTINCT along with GROUP BY in SQL Server

    Is there any purpose for using both DISTINCT and GROUP BY in SQL? Below is a sample code SELECT DISTINCT Actors FROM MovieDetails GROUP BY Actors Does anyone know of any …

  7. SQL to find the number of distinct values in a column

    247 This will give you BOTH the distinct column values and the count of each value. I usually find that I want to know both pieces of information.

  8. sql - Selecting COUNT (*) with DISTINCT - Stack Overflow

    655 In SQL Server 2005 I have a table cm_production that lists all the code that's been put into production. The table has a ticket_number, program_type, program_name and push_number …

  9. SQL - Distinct with Case When - Stack Overflow

    Sep 5, 2016 · When i use the following query it returns duplicate External IDs as it lists the different cases as different rows. SELECT DISTINCT OENT.OTHER_EXTERNAL_ID ...

  10. Is there any difference between GROUP BY and DISTINCT?

    Oct 3, 2008 · At least in Oracle 12 there do appear to be cases where DISTINCT, getting distinct values by UNION, and GROUP BY work differently. I just had a case earlier today where …