MySQL Forums
Forum List  »  General

Anyone can help to find how to solve this.
Posted by: Jung Young Go
Date: June 13, 2019 09:25PM

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

Options: ReplyQuote


Subject
Written By
Posted
Anyone can help to find how to solve this.
June 13, 2019 09:25PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.