hi
i have table with folowing columns (subid,itemid)
i want to write select stmt to get subid where itemid =all group of value('1','2')
like this
Select subid from subscriptionItem where itemId in all('1','2')
but this stmt not work
help me
Somthing like this ?Select SubID From SubscriptionItem Where ItemID in ('1','2')|||
Hi,
If you mean you want those SubID that have both ItemID 1 and 2, then the above will not work.
what you should is..
Select SubID From subscriptionItem Where ItemID in (1,2) group by SubID Having count(0) =2
Assuming that the combination SubID and ItemID is primary (unique).
If they are not unique, which I doubt, then try:
Select SubID FROM (Select distinct SubID, ItemID from SubscriptionItem where ItemID in (1,2)) si Group by SubID having count(0) = 2
Hope this helps
No comments:
Post a Comment