日期:2014-05-17 浏览次数:20877 次
CREATE TABLE ORDER_INFO1
(
order_code VARCHAR2(20),
order_type VARCHAR2(10), --类别只有 A 、B 、F - (A 、B 每个 order_code 只有一个,F 每个 order_code 可有多个 )
order_fee1 NUMBER,
order_fee2 NUMBER,
order_date VARCHAR2(10)
);
INSERT INTO ORDER_INFO1
SELECT '铅笔', 'F', 10, 20, 'CC-201310' FROM DUAL UNION ALL
SELECT '铅笔', 'F', 10, 20, 'CC-201311' FROM DUAL UNION ALL
SELECT '铅笔', 'A', 10, 20, 'CC-' FROM DUAL UNION ALL
SELECT '铅笔', 'B', 10, 20, 'CC-' FROM DUAL UNION ALL
SELECT '水笔', 'F', 10, 20, 'CC-201310' FROM DUAL UNION ALL
SELECT '水笔', 'F', 10, 20, 'CC-201311' FROM DUAL UNION ALL
SELECT '水笔', 'B', 10, 20, 'CC-' FROM DUAL UNION ALL
SELECT '水笔', 'A', 10, 20, 'CC-' FROM DUAL;
/*
要得到的结果:
ORDER_CODE FEE A B 201310 201311
铅笔 order_fee1 10 10 10 10
铅笔 order_fee2 20 20 20 20
水笔 order_fee1 10 10 10 10
水笔 order_fee2 20 20 20 20
或者这种结果也可以
ORDER_CODE A &nbs