Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dillemma regarding Distinct and Join

Status
Not open for further replies.

MayoorPatel

Programmer
Apr 10, 2006
35
GB
Hi there I have a query which is used to search a database for judgements. Each judgements can have many Categories and each category can have many subcategories.

Code:
select  j.id, sc.[description] as subcategory, sc.[id] as subcatid, c.[description] as category, c.num as catid,	
	j.file_no_1 + ' ' + j.file_no_2 + ' ' + j.file_no_3  as 'filenumber'
from judgment j
left join subcategoryjudgementmap sjm on j.id = sjm.judgement_id
left  join subcategory sc on sjm.subcategory_id = sc.id
left join category c on sc.parent_num = c.num
where j.[id] = @DecisionId

However I only want distinct judgements without losing the join. Can anyone show me how to amend my query so that it only pulls off distinct judgements.
 
you only want distinct judgements, and yet a judgement can have many categories and each category can have many subcategories?

in that case, you will have to specify which category/subcategory you want to see for each judgement -- the earliest? the one with the lowest collating description?


r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top