I have the following SQL statement:
SELECT wn_sum, COUNT(*) as count FROM cash_numbers GROUP BY wn_sum ORDER BY wn_sum ASC;
which does pretty much what I want but I like to select 1st 100 rows from wn_sum
, or last 100 rows from wn_sum
.
How would I rewrite this statement to only get first 100 rows from wn_sum
or last 100 rows from wn_sum
to get my counts?
mysql> SELECT wn_sum, COUNT(*) as count FROM cash_numbers GROUP BY wn_sum ORDER BY wn_sum ASC;
+--------+-------+
| wn_sum | count |
+--------+-------+
| 54 | 2 |
| 56 | 1 |
| 61 | 1 |
| 65 | 1 |
| 66 | 1 |
| 68 | 1 |
| 70 | 1 |
| 71 | 1 |
| 72 | 1 |
| 73 | 2 |
| 76 | 4 |
....
| 234 | 1 |
| 237 | 1 |
| 241 | 1 |
| 244 | 1 |
| 251 | 2 |
| 267 | 1 |
+--------+-------+
156 rows in set (0.00 sec)
mysql>
I did try to put limit 100, but my syntax is wrong so I get errors when I try to use those limits.