|
|

楼主 |
发表于 2007/5/15 16:38:33
|
显示全部楼层
sql
select
head.order_number,
head.order_date,
sysdate nowtime,
vend.vendor_name,
vend.vendor_number,
vend.contact_name,
vend.telephone,
sum(line.quantity * line.unit_price) as zongjine,
head.description,
line.line_number,
item.item_name,
item.item_number,
line.quantity,
line.unit_price,
(line.quantity * line.unit_price) line_money,
concat(
concat(concat(g.segment1,'.'),concat(g.segment2,'.')),
concat(concat(g.segment3,'.'),g.segment4)) as feiyongzhanghu,
line.description hhh,
(SELECT FFVT.DESCRIPTION
FROM FND_FLEX_VALUES FFV,FND_FLEX_VALUES_TL FFVT
WHERE FFV.FLEX_VALUE_ID = FFVT.FLEX_VALUE_ID
AND FFV.FLEX_VALUE_SET_ID = 1018364
AND FFV.FLEX_VALUE = g.SEGMENT1)||'-'||
(SELECT FFVT.DESCRIPTION
FROM FND_FLEX_VALUES FFV,FND_FLEX_VALUES_TL FFVT
WHERE FFV.FLEX_VALUE_ID = FFVT.FLEX_VALUE_ID
AND FFV.FLEX_VALUE_SET_ID = 1018365
AND FFV.FLEX_VALUE=g.SEGMENT2) ||'-'||
(SELECT FFVT.DESCRIPTION
FROM FND_FLEX_VALUES FFV,FND_FLEX_VALUES_TL FFVT
WHERE FFV.FLEX_VALUE_ID = FFVT.FLEX_VALUE_ID
AND FFV.FLEX_VALUE_SET_ID = 1018366
AND FFV.FLEX_VALUE=g.SEGMENT3) ||'-'||
(SELECT FFVT.DESCRIPTION
FROM FND_FLEX_VALUES FFV,FND_FLEX_VALUES_TL FFVT
WHERE FFV.FLEX_VALUE_ID = FFVT.FLEX_VALUE_ID
AND FFV.FLEX_VALUE_SET_ID = 1018367
AND FFV.FLEX_VALUE=g.SEGMENT4) FF
from trn_order_headers_5663 head,
trn_vendors_5663 vend,
trn_order_lines_5663 line,
trn_items_5663 item,
gl_code_combinations g
where head.header_id = line.header_id
and head.vendor_id =vend.vendor_id
and line.item_id = item.item_id
and CODE_COMBINATION_ID = line.expense_account_id
group by head.order_number,
head.order_date,
vend.vendor_name,
vend.vendor_number,
vend.contact_name,
vend.telephone,
head.description,
line.line_number,
item.item_name,
item.item_number,
line.quantity,
line.unit_price,
line.description,
line.expense_account_id,
g.segment1,
g.segment2,
g.segment3,
g.segment4 |
|