About 5,110,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 - Difference between Select Unique and Select Distinct - Stack …

    Dec 3, 2008 · In SQL, the UNIQUE keyword prevents two records in a column from having the same values, while the DISTINCT keyword removes duplicate values when retrieving data.

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

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

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

  5. sql - COUNT DISTINCT with CONDITIONS - Stack Overflow

    Dec 27, 2012 · If I want to count the number of distinct tags as "tag count" and count the number of distinct tags with entry id > 0 as "positive tag count" in the same table, what should I do?

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

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

    So, thanks to the SQL standard extended sort key column feature, it is totally possible to order by something that is not in the SELECT clause, because it is being temporarily added to it behind the …

  10. sql - How to use sum () together with distinct ()? - Stack Overflow

    Mar 21, 2025 · I have a table like this: state file size 1 file-1 10 2 file-2 20 2 file-2 20 2 file-3 20 I want to calculate total files under every state. But as you can, for state 2, there are two rows with the...