Forum Moderators: coopster
I am trying to run a query using 'distinct' but only for *one* field; i.e, one field in particular has lots of duplicates and I dont want any of the duplicates. However, distinct only seems to be able to apply to the entire query, i.e:
select distinct field1, field2 from table <-works fine
select field1, distinct(field2) from table <- this throws an error
is there a way to do this with distinct? thanks,
will
[webmasterworld.com...]
If this doesn't help, please explain more fully what you are trying to achieve and why.
<-works fineselect distinct field1, field2 from table<- this throws an errorselect field1, distinct(field2) from table
Hi Will,
Consider the following scenario - 'table' has 2 rows (1,3) and (2,3). If query 2 was valid, which row would be returned? It's nondeterministic - either row could be returned and that's why this query isn't valid.
If you aren't bothered about which row would be returned, you could hack it by using a 'group by':
select max(field1) from table group by field2 For example, this would return (2,3).
arran.