I am using following query to select certain values
select
sb.company
,b.id as Id
,bds.id as PId
,brp.bId
from supp b
left outer join sales bds on (bds.sId = b.id)
left outer join tperiod brp on (brp.id = bds.rId)
left outer join tbuyer sb on (sb.id = brp.bId)
where
b.ownerId = @oId;
In where b.ownerId = @old
ownerId has multiple same values in the column, I want to select distinct or unique on it. So that query is done on distinct ownerId only.
Please let me know how to achieve this.
For example : column ownerId
has values
2231
2231
2231
3341
2231
So I want the query to use only 2231 once rather than for all occurrences of 2231