Discussion Locked

SQL Script

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hello My Friends,

I'm a new member in TechRepublic.
I have a question, about SQL Script. I'm Using SQL Server 2008.

I have one table, contain 3 Fields... It's ID,STATUS,JUDGE

1. ID -- AutoNumber
2. STATUS -- Only 3 Words... PASSED, HOLD, REJECTED
3. JUDGE -- BOOLEAN (TRUE/FALSE)

I want to know the SQL Script, if i have two criteria to filter.

1. Show All records that STATUS IS NOT PASSED
2. Show All records that STATUS IS PASSED AND JUDGE IS TRUE.

SQL Script for No. 1:
SELECT * FROM TableName WHERE Status<>'PASSED'

SQL Script for No. 2:
SELECT * FROM TableName WHERE Status='PASSED' AND Judge=TRUE

How to combine the two scripts above into one script...???

Need help and advice.

Regards,
Fauzan :)

7 replies

by santeewelding

We hold our own to standards high.

I come from a place where murder in the first and most odious degree is prosecuted wherein every "i" is crossed and every "t" dotted, lest the prosecutor lose the faith of those who, in turn, prosecute him.

by shellbot

Your just looking to return both sets of data in the same result set?
If so:

Select * from tablename
where (Status <> 'passed') OR
(Status = 'Passed' and judge=true)

Or are you meaning something else?

This discussion is closed to new replies.