Home > Archive > MS SQL Server MSEQ > June 2005 > using distinct on specific columns









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author using distinct on specific columns
TC

2005-06-08, 9:23 am

Is it possible to use the DISTINCT on specific columns? For instance: a
table has ColA,ColB,ColC and I want my SELECT DISTINCT to focus on ColA and
ColB but also return ColC. However, ColC is not part of the DISTINCT clause.

Thanks
David Portas

2005-06-08, 8:24 pm

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


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com