Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

flat out query - need help

Status
Not open for further replies.

JazzMaan

Programmer
Jun 15, 2004
57
US
i have a po_item table and po_item_details table with one to many relationship. I need to display multiple records in po_item_details in a flat format.

select pi.po_item_id, pid.qualifier, descrption
from po_items pi left join po_item_identifiers pid
on (pi.PO_ITEM_ID = pid.po_Item_ID)

gives:

1, style, fall
1, color, red
1, sku, 111
2, style, fall
2, color, blue
2, sku, 112

I need to show it as:
1, fall, red, 111
2, fall, blue, 112

Thanks
 
I can accomplish the result by creating a temp table, populating it... and then in end quering it.

Is there a way to do this without creating a temp table ?
 
Which data is in which table? Sorry, it isn't too clear as you have both tables in that sample. Please post sample data from both tables seperately and it will be easier to offer advice.

BR,

M.
 

Try following:

Code:
create table myTable ( a int, b varchar( 10 ), c int )


select t0.a, t2.c, t1.c, t0.c
from 
(select a, c from myTable where b =  'sku') t0,
(select a, c from myTable where b =  'color') t1,
(select a, c from myTable where b =  'style') t2
where t0.a=t1.a and t1.a=t2.a
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top