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.
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.