Last post Mar 16, 2021 03:20 AM by XuDong Peng
Mar 15, 2021 08:49 PM|ahmedbarbary|LINK
How to get partid that have two category for same part and exist on 2000,2200 ?
I work on sql server 2012 i face issue i can't get partid that have two category for same part
and these two category must be on category 2000 and 2200
as partid 1246 it have two category for same part id
and also thesetwo category 2000 and 2200
so How to make select query do that please ?
create table #category
insert into #category(PartId,Category)
what i try :
select partid,Category from #category
where category in (2000,2200)
group by partid
Mar 16, 2021 03:20 AM|XuDong Peng|LINK
You could try a query like this:
select c.PartId,Category from #category c
select PartId, count(PartId) rowss
where Category in (2000,2200)
group by PartId
having count(PartId) = 2
on temp.PartId = c.PartId
order by PartId
Hope this can help.