SQL Query to list out Risk Score, Number of Critical, Severe and Moderate vulns

I am currently extracting this info from the Remediation Report manually, I would like to start looking to see if it’s possible to extract this info using SQL Queries.

Wanted to ask if anyone has already accomplished this using SQL queries? Could someone point me in the right direction on the best way to extract this data? Here is an example of what I’m looking to do: