Solved

How to ORDER BY after comparing two fields

Posted on 2012-04-09
2
225 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 74

Accepted Solution

by:
sdstuber earned 500 total points
ID: 37824088
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
ID: 37827489
Thanks!!!
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

832 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