I think that is the subject that I want...
Here is the deal. I am at a new job, doing some fun stuff with SQL, different than I have had to do before and am therefore asking a lot of questions (thank you for your help!). Now, on to the question. I have to do some logical flow control, which I simply did with CASE statements when there were only 2 questions, but now there are 6 and I wanted to see if anybody out there knew of a cleaner way. What I have done for 2
For all of the questions on the form, there are permissible values, so I can at least verify against known values. Now that it is up to 6 questions/criteria
I am thinking there must be a better way than trying to handle all of the questions such as I have done with just 2 questions. In essence, what I am doing is saying whether or not the specimens were handled according to SOPs given the answers to 2 to 5 questions. If the SOP was followed/met for each criteria, then it gets a 1. If any of them are a no, then it gets a 0 UNLESS any of them are missing data, in which case it gets a 9. There is also the situation where there are parent specimens and child specimens and the parent specimens SOP status has to be considered when determining the child specimen status. I have thought thru a few different ways to do this, but have not come up with an answer that I feels best fits the situation. I had started with creating a view for the SOP status of the parent specimens in which I have the specimen id and the SOP status. I was then going to create another view with more of the same logic for the child specimens when I ran into a larger number of variables and I realized that I had to rethink my approach, which brought me here...
wb
Here is the deal. I am at a new job, doing some fun stuff with SQL, different than I have had to do before and am therefore asking a lot of questions (thank you for your help!). Now, on to the question. I have to do some logical flow control, which I simply did with CASE statements when there were only 2 questions, but now there are 6 and I wanted to see if anybody out there knew of a cleaner way. What I have done for 2
Code:
WHEN sb274.SpecimenStoredID=66 AND pi274.DE385_DOTIDName='Yes' AND pi274.DE386_Centrifuged20IDName='Yes' THEN 1
WHEN sb274.SpecimenStoredID=66 AND pi274.DE385_DOTIDName='No' AND pi274.DE386_Centrifuged20IDName='No' THEN 0
WHEN sb274.SpecimenStoredID=66 AND pi274.DE385_DOTIDName='No' AND pi274.DE386_Centrifuged20IDName='Yes' THEN 0
WHEN sb274.SpecimenStoredID=66 AND pi274.DE385_DOTIDName='Yes' AND pi274.DE386_Centrifuged20IDName='No' THEN 0
ELSE 9
For all of the questions on the form, there are permissible values, so I can at least verify against known values. Now that it is up to 6 questions/criteria
Code:
question req answer
parentvalue 1
Removed without disturbing pellet yes
time from collection to storage within 0-18 hours 0-18*
Processed according to protocol yes
Was there an equipment failure/deviation from protocol no
Stored at -70C or colder yes
I am thinking there must be a better way than trying to handle all of the questions such as I have done with just 2 questions. In essence, what I am doing is saying whether or not the specimens were handled according to SOPs given the answers to 2 to 5 questions. If the SOP was followed/met for each criteria, then it gets a 1. If any of them are a no, then it gets a 0 UNLESS any of them are missing data, in which case it gets a 9. There is also the situation where there are parent specimens and child specimens and the parent specimens SOP status has to be considered when determining the child specimen status. I have thought thru a few different ways to do this, but have not come up with an answer that I feels best fits the situation. I had started with creating a view for the SOP status of the parent specimens in which I have the specimen id and the SOP status. I was then going to create another view with more of the same logic for the child specimens when I ran into a larger number of variables and I realized that I had to rethink my approach, which brought me here...
wb