August 18, 2011 at 5:20 pm
Hey everyone
August 18, 2011 at 11:27 pm
It seems a home work question :
However solution is:-
select pr.prodduct_id,pr.product_name from Product pr join
( select producti_id,(select count(1) as [States Count] from Restriction where product_id=p.Product_id group by state_id ) from Product P ) as Pro
on pro.product_id=pr.product_id
where
pro.[States Count] = ( select count(distinct state_id) from State)
Regards
Ashok
August 19, 2011 at 12:41 am
ashok.faridabad1984 (8/18/2011)
It seems a home work question :However solution is:-
select pr.prodduct_id,pr.product_name from Product pr join
( select producti_id,(select count(1) as [States Count] from Restriction where product_id=p.Product_id group by state_id ) from Product P ) as Pro
on pro.product_id=pr.product_id
where
pro.[States Count] = ( select count(distinct state_id) from State)
Regards
Ashok
August 19, 2011 at 12:43 am
There is small chnage in the script :hehe:
select pr.prodduct_id,pr.product_name from Product pr join
( select producti_id,(select count(1) as [States Count] from Restriction where product_id=p.Product_id group by product_id ) from Product P ) as Pro
on pro.product_id=pr.product_id
where
pro.[States Count] = ( select count(distinct state_id) from State)
Regards
Ashok
August 19, 2011 at 10:30 am
Thanks Ashok!:-) Appreciated.Ater thinking a little bit, I came up with this updated query:
select pr.prodduct_id,pr.product_name from Product pr join
( select product_id,count(state_id) as [States Count] from Restriction group by product_id) as Pro
on pro.product_id=pr.product_id
where
pro.[States Count] = ( select count(distinct state_id) from State)
Thanks again!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply