[AccessD] Question on order within a union query

Gustav Brock Gustav at cactus.dk
Wed Aug 8 13:13:31 CDT 2007


Hi Thomas

Never underestimate the power of a temp table!
The total time to build the report may even be shorter.

/gustav

>>> ewaldt at gdls.com 08-08-2007 17:22 >>>
Thanks, Gustav. I thought of adding a field to each of them, but in some 
cases it's a query based on a query based on a query, and tracking down to 
find and change originals and then adapting each of the subsequent puppies 
seemed too subject to error. Your solution is much nicer.

I'm going to switch to that one, but I had settled on a different 
solution: Instead of UNIONing them all, l append them all, in the correct 
order, to a table (after first clearing it out, of course), and then use 
the table. That works fine, but I like your solution better.

Thanks, again.

Thomas F. Ewald
Stryker Mass Properties
General Dynamics Land Systems

Subject: Re: [AccessD] Question on order within a union query

Hi Tom

Yes, include in each of the sections of the union query an expression to 
sort on, like:

  SELECT 1 AS SortID, ... 
  UNION ALL
  SELECT 2 AS SortID, ... 

Then Order By SortID as the first field and those fields, you currently 
sort on, as the next field(s).

/gustav





More information about the AccessD mailing list