Union操作中的静态列未提供正确的值

时间:2015-01-13 09:58:36

标签: sql oracle11g

我在Oracle中编写了以下查询:

(SELECT 'A' AS COST_POOL_#,FCCV_A.COST_CENTER, COST_CENTER_SHORT_NAME,COST_POOL as COST_POOL_A,COST_POOL_PER as COST_POOL_A_PER,
COST_SUB_POOL_A,DRIVER,DRIVER_PER,MARKUP_PERCENTAGE,MARKUP_BASE,PRICING FROM
FD_COST_CENTER_VALIDATION 
FCCV_A JOIN (SELECT COST_CENTER, MAX(S_ROWID) S_ROWID from FD_COST_CENTER_VALIDATION GROUP BY COST_CENTER) 
FCCV_B ON FCCV_A.COST_CENTER = FCCV_B.COST_CENTER AND FCCV_A.S_ROWID = FCCV_B.S_ROWID)
UNION
(SELECT 'B' AS COST_POOL_#,FCCV_A.COST_CENTER, COST_CENTER_SHORT_NAME,COST_POOL_B,COST_POOL_B_PER,COST_SUB_POOL_B,DRIVER_2,DRIVER_2_PER,MARKUP_PERCENTAGE_2,
MARKUP_BASE_2,PRICING_2 FROM
FD_COST_CENTER_VALIDATION 
FCCV_A JOIN (SELECT COST_CENTER, MAX(S_ROWID) S_ROWID from FD_COST_CENTER_VALIDATION GROUP BY COST_CENTER) 
FCCV_B ON FCCV_A.COST_CENTER = FCCV_B.COST_CENTER AND FCCV_A.S_ROWID = FCCV_B.S_ROWID)

我希望第一个查询的结果集让第一列在所有记录中都有“A”,而UNION的第二个结果集中的第一列在所有记录中都应该有“B”,但是在执行之后它不是在任何记录中给出“B”;所有记录在第一列中都有“A”。请告诉我应该更改的内容,以便我可以在第二个查询的结果集中获得“B”。

0 个答案:

没有答案