Union Query, forcing order of rows

G

Guest

Hiya,

I have a Union Query, where the last select of the union is being used to
calculate a "total" for weach column. However, Access seems to automatically
sort my rows alphabetically, so the "total" row doesnt appear at the end.
Anyone know how to force it to appear at the end?

Thanks very much for your help
Barbara

SELECT Type, Count(Type) AS [Count for that type],
Count(Vendors) AS [No. Vendor],
Count(IIf(Vendors Like '*IBM*',Null,1)) AS [No Vendors not IBM],
Sum(Cost) AS [Sum Cost]
FROM [myTable]
GROUP BY Type

UNION SELECT "Type All" AS Expr1, Count(Type) AS [Count for that type],
Count(Vendors) AS [No. Vendor],
Count(IIf(Vendors Like '*IBM*',Null,1)) AS [No Vendors not IBM],
Sum(Cost) AS [Sum Cost]
FROM [myTable]
GROUP BY "Type All"
 
J

John Spencer (MVP)

Answered in your earlier posting.

To summarize:
Add a special sort order field to both the queries and then use that as your
sort item

SELECT "Details" as LineIdentifier, Type, ...
....
UNION

SELECT "Total", "Type All", ...
....
ORDER BY LineIdentifier, ...
 

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