0

I wish to risk assess suppliers based on several criteria within my suppliers table.

For each supplier, there is a total value of products supplied, and within that, a total value for how many of them are quality assured, and based on the two previous, a percentage value.

Therefore one example would be;

FName / Sname / Total / TotalQA / QA%

John  / Smith  /   60   /   30  /  50

I want to apply a criteria to these records, so if for example the percentage is;


<40% - Status = RED

41% - 59% - Status = YELLOW

->60% - Status = GREEN


I've thought about making a new table or maybe hard coding new variables, what method would be best for accomplishing this?

1 Answer 1

1

You can use the CASE statement to do this, something like:

SELECT FName, Sname, 
       CASE WHEN QA < 40             THEN 'RED'
            WHEN QA > 40 AND QA < 59 THEN 'YELLOW'
            WHEN QA > 60             THEN 'GREEN'
       END AS 'Status'
FROM Suppliers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.