Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Get back ids based on ids having all one status

$
0
0

I have a table

CREATE TABLE [dbo].[myTable](
	[p_id] [varchar](3) NOT NULL,
	[s_id] [varchar](9) NOT NULL,
	[d_name] [varchar](9) NOT NULL,
	[status] [varchar](1) NOT NULL)

And it has the following data.

1 1 X1 N
1 1 X2 E
1 1 X3 E
1 2 Y1 E
1 2 Y2 E
1 2 Y3 E
1 3 Z1 N
1 3 Z2 N
I would like to get the p_id and s_id where all the records for a given p_id and s_id contain status = 'N'.  That is I'm look to get back p_id = 1 and s_id = 3 because all the records contain an 'N'.


lg


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>