March 31, 2015 at 7:46 am
CREATE TABLE kiQCTest (
OrderNum varchar(10),
OrderLine int,
QCPass bit)
INSERT INTO kiQCTest ([OrderNum] ,[OrderLine]) VALUES ('OD15-00010', 1)
INSERT INTO kiQCTest ([OrderNum] ,[OrderLine]) VALUES ('OD15-00010', 2)
INSERT INTO kiQCTest ([OrderNum] ,[OrderLine]) VALUES ('OD15-00010', 3)
INSERT INTO kiQCTest ([OrderNum] ,[OrderLine],[QCPass]) VALUES ('OD15-00010', 4, 1)
INSERT INTO kiQCTest ([OrderNum] ,[OrderLine],[QCPass]) VALUES ('OD15-00010', 5, 1)
INSERT INTO kiQCTest ([OrderNum] ,[OrderLine],[QCPass]) VALUES ('OD15-00010', 6, 0)
I want to write a select statement which will return one value. Thes resulting value is 'Quality Complete' if there are no NULL value in the QC Pass field in the dataset.
Or it should return me 'QC Incomplete'.
March 31, 2015 at 8:01 am
Something like this?
select kqt.OrderNum
,QCStatus = (case when count(kqt.OrderNum) - count(kqt.QCPass) > 0 then 'QC Incomplete'
else 'QC Complete'
end)
from dbo.kiQCTest kqt
group by kqt.OrderNum
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy