I have a table with following structure
col1 col2 col3 col4 category
300 200 100 20 1
200 100 30 300 2
400 100 100 70 1
100 30 200 100 1
Now i am trying to calculate for col1 what % of total rows have value <= 100, for col2 what % of total rows have value<=50 and so on and from category I only want to select category 1
so the resulting table should look like
col1(<=100) col2(<=50)
x% x%
I tried something like this but don't know how to write sub query for this
SELECT COUNT(*) AS Total, COUNT(value1)* 100 /Total) AS col1(<=100) FROM table1 WHERE Category=1 GROUP BY value1 HAVING value1 <=100
Looks like I need multiple select queries, plz help
Aucun commentaire:
Enregistrer un commentaire