Aplicación de una evaluación de riesgos contra las entradas de la base de datos (proveedores)

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?

preguntado el 28 de agosto de 12 a las 09:08

1 Respuestas

Puede utilizar el 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

Respondido 28 ago 12, 09:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.