Sort based on data from 2 fields?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a query in which the persons listed may or may not have met a certain
criterion. If they do NOT, I want them at the top of the class. If they DO, I
want them sorted by date. Can this be done?
 
Yes.

First, though, are the two fields in the same table or in two different
tables?

If in two separate tables, you'll have to have a common (key) field (or
fields) on which you can join the two tables together in a query.

Create a new query in design mode. Include the table (or joined tables -
see above) containing the fields. Select the fields you wish to have
displayed. Select the fields you wish to sort on (if not already selected).

Under the field on which you wish to sort on first (lower half of the
screen), enter your sort order (ascending/descending). Then do so for the
second field.
 
NC_Sue said:
I have a query in which the persons listed may or may not have met a certain
criterion. If they do NOT, I want them at the top of the class. If they DO, I
want them sorted by date. Can this be done?

Hi "NC_Sue",
yes you can do it.
Using Northwind database, if you want all order detail Where quantity > 50,
this is the query:

SELECT [Order Details].ProductID, [Order Details].UnitPrice, [Order
Details].Quantity, Orders.OrderDate
FROM Orders INNER JOIN [Order Details] ON Orders.OrderID = [Order
Details].OrderID
ORDER BY IIf([quantity]<=50,CDate("2010/12/31"),[OrderDate]) DESC;
 
Back
Top