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
 query

Author  Topic 

gagani
Posting Yak Master

112 Posts

Posted - 2012-08-29 : 06:04:00
contractno processA processB
101 Y N
102 Y Y
103 N N
104 N Y

I want the output with all the contracts excluding when processA <>N
and processB <>N simultaneously

The output should be
contractno processA processB
101 Y N
102 Y Y
104 N Y

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-08-29 : 07:00:27
SELECT * FROM dbo.Table1 WHERE ProcessA <> 'N' AND ProcessB <> 'N'




N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

gagani
Posting Yak Master

112 Posts

Posted - 2012-08-29 : 07:26:26
That query satisifies only the condition when both processes are 'Y'giving the output
102 Y Y

But I want the output satisfying three conditions:
processA processB
y n
y y
n y

the output should be
101 Y N
102 Y Y
104 N Y
Go to Top of Page

gagani
Posting Yak Master

112 Posts

Posted - 2012-08-29 : 07:50:23
My apologies, I didn't mention one more point, there could be repetition of contract numbers
like for example,
101 Y N
101 Y Y
101 N N
101 N Y

The output should be
101 Y N
101 Y Y
101 N Y
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2012-08-29 : 08:26:12
You say you want this
quote:

I want the output with all the contracts excluding when processA <>N
and processB <>N simultaneously




which is what Peso gave you,but your desired output shows something else. Maybe this

SELECT *
FROM yourTable
WHERE ProcessA= 'Y' or ProcessB='Y'

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -