About 10,400,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 returned in …

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

    282 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 DISTINCT …

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

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

    656 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 along …

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

    Sep 10, 2008 · 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 functions.

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

    Apr 5, 2019 · SELECT COUNT(DISTINCT column_name) AS some_alias FROM table_name This will count only the distinct values for that column.

  7. 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 DISTINCT and …

  8. c# - Entity Framework select distinct name - Stack Overflow

    Dec 27, 2010 · How can I do this SQL query with Entity Framework? SELECT DISTINCT NAME FROM TestAddresses

  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. 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) TOP 10 * …