R
rachael
I have a union query that is combining the results of several other queries.
I have a specific sort order that I need to maintain – this sort order is
built into the individual queries, but not the union query that joins them
together. The problem is there is no easy way to use ORDER BY on the union
results to get the order I need. What I need at the end is an order like:
Organization A – [blank field] – [blank field] – Geography A
Organization A – [blank field] – [blank field] – Geography B
Organization A – [blank field] – [blank field] – Geography C
--------------------------------------------------------------------- [end
of 1st query]
Organization O – [blank field] – [blank field] – [blank field]
Organization O – [SubOrg A] – [blank field] – [blank field]
Organization O – [SubOrg A] – [Group A] – [blank field]
Organization O – [SubOrg A] – [Group B] – [blank field]
Organization O – [SubOrg A] – [Group C] – [blank field]
Organization O – [SubOrg B] – [blank field] – [blank field]
Organization O – [SubOrg C] – [blank field] – [blank field]
--------------------------------------------------------------------- [end
of 2nd query]
Organization M – [blank field] – [blank field] – [blank field]
Organization M – [SubOrg A] – [blank field] – [blank field]
Organization M – [SubOrg B] – [blank field] – [blank field]
Organization M – [SubOrg C] – [blank field] – [blank field]
--------------------------------------------------------------------- [end
of 3rd query]
Organization C – [blank field] – [blank field] – [blank field]
Organization D – [blank field] – [blank field] – [blank field]
Organization E – [blank field] – [blank field] – [blank field]
--------------------------------------------------------------------- [end
of 4th query]
etc...
I can’t really create a static table (or don’t know how) that lists the
proper sort order for these results, which I could then link to the union
results to sort after the fact. The organizations, etc. in this data will
change over time and it would be difficult to maintain a static table. Any
advice?
Thanks
rachael
I have a specific sort order that I need to maintain – this sort order is
built into the individual queries, but not the union query that joins them
together. The problem is there is no easy way to use ORDER BY on the union
results to get the order I need. What I need at the end is an order like:
Organization A – [blank field] – [blank field] – Geography A
Organization A – [blank field] – [blank field] – Geography B
Organization A – [blank field] – [blank field] – Geography C
--------------------------------------------------------------------- [end
of 1st query]
Organization O – [blank field] – [blank field] – [blank field]
Organization O – [SubOrg A] – [blank field] – [blank field]
Organization O – [SubOrg A] – [Group A] – [blank field]
Organization O – [SubOrg A] – [Group B] – [blank field]
Organization O – [SubOrg A] – [Group C] – [blank field]
Organization O – [SubOrg B] – [blank field] – [blank field]
Organization O – [SubOrg C] – [blank field] – [blank field]
--------------------------------------------------------------------- [end
of 2nd query]
Organization M – [blank field] – [blank field] – [blank field]
Organization M – [SubOrg A] – [blank field] – [blank field]
Organization M – [SubOrg B] – [blank field] – [blank field]
Organization M – [SubOrg C] – [blank field] – [blank field]
--------------------------------------------------------------------- [end
of 3rd query]
Organization C – [blank field] – [blank field] – [blank field]
Organization D – [blank field] – [blank field] – [blank field]
Organization E – [blank field] – [blank field] – [blank field]
--------------------------------------------------------------------- [end
of 4th query]
etc...
I can’t really create a static table (or don’t know how) that lists the
proper sort order for these results, which I could then link to the union
results to sort after the fact. The organizations, etc. in this data will
change over time and it would be difficult to maintain a static table. Any
advice?
Thanks
rachael