Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8954007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:13:10+00:00 2026-06-15T14:13:10+00:00

I want to get a table like this Display the books we have, ranked

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:13:11+00:00Added an answer on June 15, 2026 at 2:13 pm

    I think you are looking for something like this:

    select
      book_id,
      page_count,
      (select count(distinct b2.page_count DIV 50)
       from books b2
       where b2.page_count DIV 50 >= books.page_count DIV 50) as page_rank
    from books
    order by page_count desc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know, can I do this mark up use just display: table;
I want to get table metadata for all table columns. Like type string(varchar2)/int/float/datetime and
In mssql2005 when I want to get size of table in MBs, I use
I have a section of an html page that I want to display in
I have a table named listing_fees and I want to get the data by
I have a MYSQL table like this: id | userid | score | datestamp
I have a table and data like this id | term_id | name_id 1
I want to display the grid view like this -(fig 1) Sr.no Class ----Division------
I have a table that is setup like this: +----+-------+-------+ | id | col1
I have a User class and want to display many users' thumbnails w/ their

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.