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 8911669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:00:22+00:00 2026-06-15T04:00:22+00:00

I have a table which looks like the following: Name LastName tPoints aPoints sPoints

  • 0

I have a table which looks like the following:

Name LastName tPoints aPoints sPoints gPoints type
John   Johnny   15      14     13      10       1
Joe     P.      12      11     26      10       1
Matt    Q.      11      26     37      44       2
Sorine  P.      55      9      8        7       2
Ali     Ahmed   30      44     88      65       2 
...     ...     ..      ..      ..     ..       3            
                                                3

I would like to sort INDIVIDUAL ROWS and display based on TYPE

NOTE: i can't use order by in oracle because it sorts only 1 row and the others
is sorted based on the first row

I don’t want to break the table apart into individual tables, then sort it, and then update it back to the original table.

so, the output will looks something like this, for tPoints – i need to display all

15  - John Johnny
12  - Joe P. 

and for aPoints

44  - Ali Ahmed
26  - Matt Q.
 9  - Sorine P.

and so on …

in a nutshell, if type = 1 then sort tPoints in descending, if type = 2 then sort aPoints, if type = 3 then sort sPoints, and so on….

what would be an efficient way to chive this?

Regards,

  • 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-15T04:00:23+00:00Added an answer on June 15, 2026 at 4:00 am

    For the sake of simplicity this example includes only two types. Add as many types as you need.

    SQL> with t1(Name1, LastName, tPoints, aPoints, sPoints, gPoints, type1) as(
      2  select 'John'  ,  'Johnny',  15,  14,  13,  10,   1  from dual union all
      3  select 'Joe'   ,  'P.'    ,  12,  11,  26,  10,   1  from dual union all
      4  select 'Matt'  ,  'Q.'    ,  11,  26,  37,  44,   2  from dual union all
      5  select 'Sorine',  'P.'    ,  55,  9 ,  8 ,  7,    2  from dual union all
      6  select 'Ali'   ,  'Ahmed' ,  30,  44,  88,  65,   2   from dual
      7  )
      8  select type1
      9       , tpoints
     10       , apoints
     11       , name1
     12       , Lastname
     13    from t1
     14   order by case when type1=1 then tpoints else type1 end desc,
     15            case when type1=2 then apoints else type1 end desc;
    
         TYPE1    TPOINTS    APOINTS NAME1  LASTNAME
    ---------- ---------- ---------- ------ --------
             1         15         14 John   Johnny
             1         12         11 Joe    P.
             2         30         44 Ali    Ahmed
             2         11         26 Matt   Q.
             2         55          9 Sorine P.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table which looks like the following ID Name Year Jan Feb
I have this mysql table called comments which looks like this: commentID parentID type
I am having the following issue : I have a table which looks like
I have a table which looks like this: mysql> SHOW COLUMNS FROM Users; +------------+--------------+------+-----+---------+----------------+
I have a table which looks like this: <table id='t'> <thead> .... </thead> <tbody
I have a table which looks like this one: | id | fk_book |
I have two tables which looks something like this Table Queue int ID; string
I have jQuery code which looks something like this on Button1 Click $('table.result_grid tbody
I have a table that looks something like this: CREATE TABLE student_results(id integer, name
I have a categories table that looks like this: id | name | parent

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.