
Yargh! Sorting UNION'd SQL query
Hello all, I've got my sorting and grouping almost sussed out, but am a bit
flummoxed by the following factoid:
My query is two subqueries UNION'd together so that the code tests all jobs
matching its TEAM field, then goes to all jobs NOT matching. I'd like the
jobs in Query1 to sort by Priority descending (100 first, 0 last), and then
the jobs in Query2 sorting the same way (but *after* query1, you know?)
Here's what I have:
JOBSQL = "SELECT * from Jobs WHERE Team = '" & eRs.Fields("Team") & "' ORDER
BY Priority DESC UNION ALL SELECT * From Jobs WHERE Team <> '" &
eRs.Fields("Team") & "'"
Set jrs = db.OpenRecordset(JOBSQL, dbOpenSnapshot)
First off, is "WHERE Team <> eRs.fields("Team") a valid way to search for
outsiders? Not a{*filter*} of this in VB Help or Books Online, much to my
chagrine.
Second, if I sort the second query by priority then *everything* gets all
mixed together, not what I'm looking to do. Help? Ideas? Small flightless
waterfowl?