Query Order By then By...

S

SusanV

Hi all,

I often use the query design view to put together quick and dirty queries on
my database that I will never use again, that I don't need a report for,
just need to get this particular data this one time for someone.

Is there a way to order by 2 fields - say by Date then by OrderNo in SQL or
in the design view? I know you can do multi-tiered sorting in a report, but
I don't need a report. What I've been doing is dumping it to Excel then
using Excel's sorting, but that adds another step I'd like to eliminate.

TIA,
Susan
 
F

fredg

Hi all,

I often use the query design view to put together quick and dirty queries on
my database that I will never use again, that I don't need a report for,
just need to get this particular data this one time for someone.

Is there a way to order by 2 fields - say by Date then by OrderNo in SQL or
in the design view? I know you can do multi-tiered sorting in a report, but
I don't need a report. What I've been doing is dumping it to Excel then
using Excel's sorting, but that adds another step I'd like to eliminate.

TIA,
Susan

In SQL view?:
Select .... etc.... Order By
TableName.[DateField],TableName.[OrderNo];

In Query Design View?:
Access queries sort from Left to Right.
Drag the DateField column to the left of the OrderNo column.
Select Ascending (or Descending) in the column's Sort row.
 
M

Marshall Barton

SusanV said:
I often use the query design view to put together quick and dirty queries on
my database that I will never use again, that I don't need a report for,
just need to get this particular data this one time for someone.

Is there a way to order by 2 fields - say by Date then by OrderNo in SQL or
in the design view? I know you can do multi-tiered sorting in a report, but
I don't need a report. What I've been doing is dumping it to Excel then
using Excel's sorting, but that adds another step I'd like to eliminate.


In SQL just use an ORDER BY OrderDate, OrderNo
(Use ASC or DESC to specify ascending or descending sorts,
the default is ASC)

In the query design grid, set each field's Sort option to
Ascending/Descending. To specify which field is the promary
sort field, make sure it is to the left of the secondary
sort field. If you can not tolerate the fields being
display in the "wrong" columns, then add one of the fields a
second time and use this one to sort by. (Be sure uncheck
its Show box so it doesn't appear in the query results)
 
J

John Spencer

In the query grid, there is a sort by line. The sort will by will be in the
order of the fields, however, if you want to display the fields in one order
and sort them in another order, just add the fields to the end of the grid a
second time, uncheck the DISPLAY and then set the sort to ascending or
descending.
 
S

SusanV

Thanks to you all - I knew it had to be something totally simple!

<buries head in sand>

Susan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top