I have a query I need to run, but I'm not sure how to create it.Each part number in our database can be tested multiple times at each of our test stations.Declare Serial_Number varchar(20) -- this is the part numberDeclare Test_Result varchar(255) -- this stores the test resultDeclare System_ID varchar(50) -- the test station nameDeclare Date_Time Datetime -- when test was performed
One of the floor managers wants me to generate a one time report that shows the number of parts that passed the first time for all parts that start with 'C710303 %'.I made a quick call toselect count(distinct Serial_Number)from dbo.Resultswhere (Serial_Number Like 'C710303 %')
and I see the number 476.How could I write a query that counts the number of parts where the first Test_Result entry for it contains the text 'pass'?Select Serial_Numberfrom dbo.resultswhere (Test_Result Like '%pass%')
will return all parts, because everything eventually passes.I'm happy to explain further, if this doesn't make sense.
Avoid Sears Home Improvement