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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query

Status
Not open for further replies.

Rickspx

Programmer
Feb 2, 2003
14
GB
Hi,

I have a table T1 which contains style(PK) and Product and another table T2
which contains style (PK) and some other cols.I want the result as 1 if all the styles of a product in T1 exists in t2
otherwise 0.How Can I write a query ,can somebody help.

Rick

 
Are the styles in t2 a subset of those in t1 for each product?

select product, case when count(distinct style) = (select count(distinct style) from t2
where productId = t1.productid) then 1 else 0 end
from t1
group by product
 
Thanks.This is want was required.But Can we have a query
without using the count function?

Thanks again

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top