I have some data like this:
+----+--------+-------+
| id | height | width |
+----+--------+-------+
| 1 | 1000 | 300 |
| 2 | 1024 | 330 |
| 3 | 600 | 200 |
| 4 | 624 | 311 |
| 5 | 724 | 511 |
| 6 | 300 | 200 |
+----+--------+-------+
with many more rows.
I’d like to run a query that does something like this:
Count how many rows have a height between 0 and 400, between 401 and 600, between 601 and 1000, and 1000+
In this case, I’d want it to return something like this:
+-------+---------+----------+-------+
| 0-400 | 401-600 | 601-1000 | 1000+ |
+-------+---------+----------+-------+
| 1 | 1 | 3 | 1 |
+-------+---------+----------+-------+
I’m going to hard code the ranges.
Currently, I’m planning to run a query for each range, is there a better way?
Try something like this:
g