sql - MS Access Union Query Order by Select statements -


i attempting union 3 different pipe delimited tables 1 can export 1 text file. each pipe delimited table has different structure. here have far. when run union query sorting query 2, query 1, query 3; sure because of output of each query doing final sort on abc order. there way sort order of query?

 select  qry_header.hdr    qry_header   union   select qry_ghd_headers.ghd_header    qry_ghd_headers inner join [coverage id] on qry_ghd_headers.        [coverage id] = [coverage id].[coverage id]  [coverage id].id = 1   union    select   [qry_pipe_delim].pipe_delim   qry_pipe_delim inner join [coverage id] on qry_pipe_delim.  [coverage id] = [coverage id].[coverage id]  [coverage id].id = 1 

output looks this:

 ghd|ca015015hl|tm|f|20150414  hdr|10|p00000000020123|axqen16e88|rxhub|optumrx|cp000005|20150415|104818|frm|u|20150414|p  tdt|a|ca015015hl|00008112312|003|||||this medication increases risk of serious toxicity in patients 65 , older. use safer alternatives.|national guidelines , quality measures recommend avoiding medication in patients 65 yrs , older due incre 

preferred output:

 hdr|10|p00000000020123|axqen16e88|rxhub|optumrx|cp000005|20150415|104818|frm|u|20150414|p  ghd|ca015015hl|tm|f|20150414  tdt|a|ca015015hl|00008112312|003|||||this medication increases risk of serious toxicity in patients 65 , older. use safer alternatives.|national guidelines , quality measures recommend avoiding medication in patients 65 yrs , older due incre 

i figured out - @ least workaround works

 select hdr  from(  select  1, qry_header.hdr    qry_header   union    select 2, qry_ghd_headers.ghd_header     qry_ghd_headers inner join [coverage id] on qry_ghd_headers.         [coverage id] = [coverage id].[coverage id]   [coverage id].id = 1    union    select 3,  [qry_pipe_delim].pipe_delim   qry_pipe_delim inner join [coverage id] on qry_pipe_delim.  [coverage id] = [coverage id].[coverage id]  [coverage id].id = 1) 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -