0

I am returning a set of records that may contain some rows that are identical except for one specific column. I am not interested in this column so it doesn't need to be part of the recordset.

Is the best way to use SELECT DISTINCT and leave out the column that may be different?

Is there a way to do this while still being able to use * in the SELECT clause, or would you have to list all the columns?

CJ7
  • 22,579
  • 65
  • 193
  • 321

2 Answers2

0

Yes, SELECT DISTINCT is the way to go, and no, by definition * includes all of the columns from that particular table or joined tables which would also include the column that is different and the records would no longer be distinct.

Sandi Hrvić
  • 211
  • 1
  • 1
0

The DISTINCT keyword can be used to return only distinct (different) values. It verifies the entire result set, so if you don't need the column that may be different leave it out and to do this you have to list all the columns you want in the result set, there is no:

select *, exclude (column_name) from table
Euclides Mulémbwè
  • 1,677
  • 11
  • 18