Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Return Value base on record with Multiple Types

Author  Topic 

jsaltmarsh
Starting Member

1 Post

Posted - 2015-01-15 : 00:33:46
I want to return Order records which are one type and don't have the other type.
The issue is I have Orders with which has 2 distriubtion types .
Example
Order 12345 has Type S and Type X.
Order 67891 has Type S
I only want to return Order 67891 that are s Type and does not have type X

razeena
Yak Posting Veteran

54 Posts

Posted - 2015-01-15 : 01:06:57
Can try this..there may be better solution than this..

declare @test table (id int, OrderType char(1))
insert into @test values(12345,'s')
insert into @test values(12345,'x')
insert into @test values(67891,'s')
select * from @test
select * from @test where ordertype like 's'
and id not in
(select id from @test where ordertype like 'x')
delete @test
Go to Top of Page
   

- Advertisement -