Using the following query:
SELECT sum(severity) as Score, DATE_FORMAT(LAST_UPDATE,"%Y-%m") as
score_date
FROM missingpatches
GROUP BY score_date
Is there a way within the query to assign a value for each of the numbers in the ‘severity’ column and then sum these new values?
For example right now I have:
Severity Last_Update
1 5/1/2012
1 5/1/2012
2 5/1/2012
2 5/1/2012
3 5/1/2012
3 5/1/2012
And I would like all 1s to have a score of 10, 2’s to have a score of 9 and 3s to have a score of 6
Is there a way to do this within the query? Or is there a way to insert the scores for each severity into the table automatically using a trigger every time new severity numbers are entered?
You can try using
CASE WHEN THEN