Re: using distinct on specific columns



Which value would you want to see in ColC in that case? You could use an
aggregate, but it all depends on what result you want:

SELECT cola, colb, MAX(colc) AS colc
FROM YourTable
GROUP BY cola, colb

--
David Portas
SQL Server MVP
--


.



Relevant Pages

  • Re: PHP/MySQL - Splitting similar data to two tables and querying as a whole
    ... > data - previous years stuff, which is only used in queries <5% of the ... select colA, colB, colC ...
    (comp.lang.php)
  • Re: id record for each table
    ... row ordering the rows by colA, colB descending, colC, where (colA, colB, ... No identity field but just a internal flag or hide field which computes each record. ...
    (microsoft.public.sqlserver.programming)
  • Re: Query Error
    ... INSERT INTO (colA, colB, colC) ... but I am getting an error message: runtime error 3134: SYNTAX ERROR IN INSERT INTO statement. ...
    (microsoft.public.access.queries)
  • Re: converting from long to double
    ... decimals). ... Append query - like this (say colC is the converting column): ... SELECT colA, colB, Val ...
    (comp.databases.ms-access)
  • Re: Join on alias field values on-the-fly
    ... Ohh becuase we can have a scenario where there is other things in ColC ... where ColA and ColB match. ... So use that in your join: draw a line from ColA to ColA, and from ColB ...
    (comp.databases.ms-access)