views:

66

answers:

4

I want to do a SELECT DISTINCT guid, ..., but I don't want guid appearing in the recordset. How do I do this?

+5  A: 
SELECT a.Field2
     , a.Field3
  FROM (SELECT DISTINCT a.guid
                      , a.Field2
                      , a.Field3
                   FROM table1 a)  a
dcp
damn, you were 20 seconds faster ;-)
meriton
That's why he has the gold :)
@meriton - :) At least we both arrived at the same solution.
dcp
+2  A: 

Wrap it in a subselect?

select my, interesting, columns
from (
    select distinct GUID, ...
    from ...
)
meriton
Deleted my answer as it would have returned everything, this is the correct solution +1!
GenericTypeTea
I have to choose this one as the answer, because it actually has an English answer in it! :P
A: 

select the distinct values into a temp table first.

Then select out only the values you want.

sparkkkey
+3  A: 

You can also do

SELECT x, y FROM tbl GROUP BY guid, x, y

The drawback here is that you have to duplicate the column list in the GROUP BY clause, which is annoying, but the other answers do as well.

egrunin