Solved

Sort by the sum of two columns in an SQL Table

Posted on 2007-11-27
2
2,656 Views
Last Modified: 2012-06-27
SELECT trip_no,c_pilot_no AS PILOT,flight_hrs,flight_hrs_wait AS WAIT_HRS,flight_hrs + flight_hrs_wait AS TOTAL
FROM c_charter
ORDER BY c_pilot_no ASC
ORDER BY flight_hrs + flight_hrs_wait DESC;

The last line of code, the ORDER BY, is not working like I thought it would.  I need this select query to be ordered by the TOTAL column as created above.  It lists out correctly, but I cannot get the query to be sorted in order by the TOTAL column.
0
Comment
Question by:josephdaviskcrm
2 Comments
 
LVL 1

Expert Comment

by:bobbymanocha
ID: 20359703
SELECT trip_no,c_pilot_no AS PILOT,flight_hrs,flight_hrs_wait AS WAIT_HRS,flight_hrs + flight_hrs_wait AS TOTAL
FROM c_charter
ORDER BY c_pilot_no ASC, flight_hrs + flight_hrs_wait DESC;
0
 
LVL 13

Accepted Solution

by:
sonicefu earned 500 total points
ID: 20363409
SELECT trip_no,c_pilot_no AS PILOT,flight_hrs,flight_hrs_wait AS WAIT_HRS,flight_hrs + flight_hrs_wait AS TOTAL
FROM c_charter
ORDER BY PILOT ASC, TOTAL DESC;
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now