Solved

Sort by the sum of two columns in an SQL Table

Posted on 2007-11-27
2
2,707 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

729 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