Informix SQL - Cross Tab Query?
Posted in 1999
I have a situation where I would like a cross tab query for a particular
table, can Informix SQL handle "Cross Tab Queries", and how might I go about
coding it through standard Informix SQL, no application or UNIX scripting?
The table :stoshipd
The following SQL produces the following results:
select doc_no, line_no, ship_qty, curr_stage
from stoshipd
where doc_no=37337
order by 1 asc, 2 asc, 4 asc
doc_no line_no ship_qty curr_stage
37337 1 1.0000000000000 PST
37337 2 6.0000000000000 PST
37337 3 6.0000000000000 PST
37337 4 5.0000000000000 BKO
37337 4 1.0000000000000 PST
37337 5 2.0000000000000 PST
37337 6 1.0000000000000 PST
What I would like to see the following:
Notice line 4 had a multiple shipment lines where 5 where in a BKO stage and
1 was in a PST stage, there could also be other stages. I would like to see
the quantities going across.
doc_no line_no ship_qty curr_stage ship_qty
curr_stage
37337 1 1.0000000000000 PST
37337 2 6.0000000000000 PST
37337 3 6.0000000000000 PST
37337 4 1.0000000000000 PST
5.0000000000000 BKO
37337 5 2.0000000000000 PST
37337 6 1.0000000000000 PST
Any help would be greatly appreciated.
TIA,
John E. Porcello, Jr.
Corporate DBA
Kaman Corporation
jep-corp@kaman.com
My views and opinions may not reflect those of Kaman Corporation.