Solved

How to ORDER BY after comparing two fields

Posted on 2012-04-09
2
223 Views
Last Modified: 2012-04-10
Hello

I  am trying to create a report that will produce information about the cars in our shop.  In my report, I am trying to pull a report and order by   all of the cars that have not been driven at all, all of the cars that have been driven initially by a test driver and the most recent driver who is a manager, and then all cars that have been driven most recent to the oldest.  It is possible that the manager.driver is also the tester.testdriver. So, I want to have this ordered in my report after I see a list of all the cars that have not been driven.  How to I check to see if two fields are equivalent and order them?  If you need more information let me know.

In my ORDER BY, I have

ORDER BY cars.driven is null desc,tester.testdriver == manager.driver , tester.testdriver desc
0
Comment
Question by:tncode
2 Comments
 
LVL 73

Accepted Solution

by:
sdstuber earned 500 total points
Comment Utility
ORDER BY cars.driven is null desc,
case when tester.testdriver = manager.driver  then 1 else 2 end,
tester.testdriver desc
0
 
LVL 6

Author Closing Comment

by:tncode
Comment Utility
Thanks!!!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

728 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

12 Experts available now in Live!

Get 1:1 Help Now