Texas Count

MariaDB [letter]> SELECT
-> CASE
-> WHEN NBR_POWER_UNIT BETWEEN 1 AND 5 THEN ‘1-5’
-> WHEN NBR_POWER_UNIT BETWEEN 6 AND 10 THEN ‘6-10’
-> WHEN NBR_POWER_UNIT BETWEEN 11 AND 15 THEN ’11-15′
-> WHEN NBR_POWER_UNIT BETWEEN 16 AND 20 THEN ’16-20′
-> WHEN NBR_POWER_UNIT BETWEEN 21 AND 25 THEN ’21-25′
-> WHEN NBR_POWER_UNIT BETWEEN 26 AND 30 THEN ’26-30′
-> WHEN NBR_POWER_UNIT BETWEEN 31 AND 35 THEN ’31-35′
-> WHEN NBR_POWER_UNIT BETWEEN 36 AND 40 THEN ’36-40′
-> WHEN NBR_POWER_UNIT BETWEEN 41 AND 45 THEN ’41-45′
-> WHEN NBR_POWER_UNIT BETWEEN 46 AND 50 THEN ’46-50′
-> END AS power_unit_range,
-> COUNT(DISTINCT DOT_NUMBER) AS unique_carrier_count
-> FROM inner1123
-> WHERE PHY_STATE = ‘TX’ AND NBR_POWER_UNIT >= 1 AND NBR_POWER_UNIT <= 50 -> GROUP BY power_unit_range
-> ORDER BY MIN(NBR_POWER_UNIT);
+——————+———————-+
| power_unit_range | unique_carrier_count |
+——————+———————-+
| 1-5 | 55387 |
| 6-10 | 3808 |
| 11-15 | 1512 |
| 16-20 | 841 |
| 21-25 | 499 |
| 26-30 | 361 |
| 31-35 | 227 |
| 36-40 | 212 |
| 41-45 | 144 |
| 46-50 | 126 |
+——————+———————-+
10 rows in set (5.711 sec)



MariaDB [letter]> SELECT
-> CONCAT(FLOOR(NBR_POWER_UNIT / 50) * 50, ‘-‘, FLOOR(NBR_POWER_UNIT / 50) * 50 + 49) AS power_unit_range,
-> COUNT(*) AS carrier_count
-> FROM
-> inner1123
-> WHERE
-> PHY_STATE = ‘TX’
-> GROUP BY
-> power_unit_range
-> ORDER BY
-> FLOOR(NBR_POWER_UNIT / 50);

+——————+—————+
| power_unit_range | carrier_count |
+——————+—————+
| 0-49 | 64079 |
| 50-99 | 580 |
| 100-149 | 196 |
| 150-199 | 102 |
| 200-249 | 50 |
| 250-299 | 33 |
| 300-349 | 37 |
| 350-399 | 15 |
| 400-449 | 11 |
| 450-499 | 14 |
| 500-549 | 9 |
| 550-599 | 7 |
| 600-649 | 10 |
| 650-699 | 4 |
| 700-749 | 4 |
| 750-799 | 7 |
| 800-849 | 5 |
| 850-899 | 5 |
| 900-949 | 3 |
| 950-999 | 8 |
| 1000-1049 | 3 |
| 1100-1149 | 1 |
| 1200-1249 | 2 |
| 1250-1299 | 4 |
| 1300-1349 | 3 |
| 1350-1399 | 1 |
| 1600-1649 | 1 |
| 1750-1799 | 2 |
| 1900-1949 | 2 |
| 1950-1999 | 2 |
| 2000-2049 | 1 |
| 2050-2099 | 2 |
| 2150-2199 | 1 |
| 2350-2399 | 1 |
| 2500-2549 | 1 |
| 2700-2749 | 1 |
| 2950-2999 | 1 |
| 3000-3049 | 1 |
| 3500-3549 | 1 |
| 3650-3699 | 1 |
| 3850-3899 | 1 |
| 4000-4049 | 1 |
| 6000-6049 | 1 |
| 6750-6799 | 1 |
| 7150-7199 | 1 |
| 7250-7299 | 1 |
| 10000-10049 | 1 |
| 11350-11399 | 1 |
| 13500-13549 | 1 |
| 15300-15349 | 1 |
| 18000-18049 | 1 |
| 30000-30049 | 1 |
| 32000-32049 | 1 |
| 40000-40049 | 1 |
| 55000-55049 | 1 |
| 199950-199999 | 1 |
+——————+—————+
56 rows in set (6.539 sec)