I want to get a table like this
Display the books we have, ranked by their page count. We want to use a 50-page range for ranking the page counts. This means that any book with page counts 500-549 have the same rank; page counts 550-599 have the same rank; page counts 600-649 have the same rank; page counts 650-699 have the same rank, etc. In the sample display we have four books which are all at rank 3. Note that we are not skipping rank numbers- examine the first two sample rows. Do not make assumptions about the maximum page count value. When designing the logic of the query. do not use the current set of data in the table to make decision about the logic.
+---------+------------+------+
| Book_ID | Page_count | Rank |
+---------+------------+------+
| 1001 | 2000 | 1 |
| 1587 | 1300 | 2 |
| 8546 | 982 | 3 |
| 8415 | 980 | 3 |
| 1474 | 976 | 3 |
| 1444 | 970 | 3 |
| 1524 | 918 | 4 |
| 2005 | 894 | 5 |
| 200 | 879 | 5 |
| 201 | 850 | 5 |
| 4574 | 825 | 6 |
| 6584 | 825 | 6 |
EDITED: Now I have
SELECT b.book_id AS Book_ID, b.page_count as Page_Count, (
SELECT COUNT(DISTINCT page_count)
FROM a_bkinfo.books as b2
WHERE b2.page_count >= b.page_count
) as Rank
FROM a_bkinfo.books as b
ORDER BY Page_Count DESC
Now I get this result
Book_ID Page_Count Rank
1448 3192 1
1306 2895 2
1979 1368 3
1678 1002 4
1677 982 5
1689 980 6
I need to figure out how to do the 50 page range
I think you are looking for something like this: