Reputation: 2409
I wanted to use distinct clause only for one column.I am having query like this
select id,brandname from brand.
Here brandname have same entry multiple time.I wanted to choose distinct brandname along with id.
Upvotes: 0
Views: 358
Reputation: 4572
You have to pick some way of getting only one ID, e.g.,
select max(id) , brandname
from brand
group by brandname
if you had more than one column you wanted... if the data was the same you could just continue to group by... however if extra columns had varying data you could use a slightly different strategy.
select * from brand
where id in
(
select max(id)
from brand
group by brandname
)
Upvotes: 1
Reputation: 1668
You can do this:
select Id,BrandName from brand group by BrandName,Id
Upvotes: 0