'How to get Parts that have two different value source type?
I work on sql server 2017 i need to get part id that have two different source type
per same part .
but part have two different source type per part
and it must have one source type from two source type equal 8901 .
sample data
create table #temp
(
partid int,
sourcetypeid int
)
insert into #temp(partid,sourcetypeid)
values
(1290,5012),
(1290,5012),
(1290,8901),
(3501,5402),
(3501,74430),
(7001,8901),
(7321,8900),
(2040,5090),
(2040,5400),
(7321,7400),
(9110,8901),
(9110,8901)
what i try
select partid from #temp
where sourcetypeid=8901
group by partid
having count(distinct sourcetypeid)=2
but it return null
expected result
partid that have two different source type at least source type 8901 must exist
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
