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

  • SEARCH
  • Home
  • 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 8701393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:23:19+00:00 2026-06-13T02:23:19+00:00

I have a table with roll_no & No_of_items (Both not primary) Is it possible

  • 0

I have a table with roll_no & No_of_items (Both not primary)

Is it possible to order them the following way: The first entry is with the highest no of items, then all the entries belonging to that roll_no come, then the next entry from a diff roll_no that has the highest no of items and then all the entries belonging to that client and so on

For Eg.

Column 1 Column 2
A          12
A          05
C          19
C          18
C          02 
B          05

Should display as:

C 19
C 18
C 02
A 12
A 05
B 05
  • 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-13T02:23:20+00:00Added an answer on June 13, 2026 at 2:23 am

    Try this.

    select t1.*
    from yourtable t1
        inner join 
        (
            select 
                client_id, max(numberofdays) cnt 
            from yourtable 
            group by client_id
        ) t2
            on t1.client_id = t2.client_id
    order by cnt desc, client_id, numberofdays desc;
    

    This may also work, dependant on SQL flavour

    select *
    from yourtable
    order by 
        max(numberofdays) over (partition by client_id) desc, 
        client_id, 
        numberofdays desc;
    

    Edit: added client_id to order to keep rows with same number.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML structure like the following: <tables> <table name=tableName1> <row ID=34 col1=data
I have a table mytable in ORACLE database having only one column Roll_no like
I have a table in database in which there is a column named roll_no,
I have the below Declare @tbl Table(Id int identity, SomeCol varchar(10) not null) Begin
Let's say you have a table for branches in your organization. Some of them
I have a messcuts table with the following structure. id , student_rollno , date
I have a table like this: id | roll_no | name --------------------- 1 |
i have a table which consists of student details like roll no, Name, age.
I have table with around 70 000 rows. There is 6000 rows that i
I have table in which I am inserting rows for employee but next time

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.