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

    DISTINCT works to select a distinct combination of all the columns you selected. In this case, the combination "item1,data1" and "item1,data2" are two completely different combinations of the …

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

  3. MySQL: Select DISTINCT / UNIQUE, but return all columns?

    May 25, 2011 · SELECT DISTINCT FIELD1, FIELD2, FIELD3 FROM TABLE1 works if the values of all three columns are unique in the table. If, for example, you have multiple identical values …

  4. sql - DISTINCT e GROUP BY, qual a diferença entre ambas as …

    Aug 11, 2017 · DISTINCT A instrução SELECT DISTINCT é usada para retornar apenas valores distintos (diferentes). Dentro de uma tabela, uma coluna geralmente contém muitos valores …

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

    SELECT DISTINCT TOP 2 name FROM [ATTENDANCE] ; In the above query, name is the column_name and [ATTENDANCE] is the table_name. You can also use WHERE with this to …

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

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

    Feb 19, 2017 · SELECT DISTINCT TOP 1 ID, Email, ProductName, ProductModel FROM Products ORDER BY ID DESC The TOP 1 will return only the first record, by ordering it by the …

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

  9. sql - Counting DISTINCT over multiple columns - Stack Overflow

    Sep 24, 2009 · SELECT COUNT(*) FROM (SELECT DISTINCT DocumentId, DocumentSessionId FROM DocumentOutputItems) AS internalQuery I need to count the number of distinct items …

  10. sql - Difference between Select Unique and Select Distinct - Stack …

    Dec 3, 2008 · Use SELECT DISTINCT because this is standard SQL, and SELECT UNIQUE is non-standard, and in database brands other than Oracle, SELECT UNIQUE may not be …