日期:2014-05-17  浏览次数:20806 次

ORACLE使用PL/SQL查询问题
在使用PL/SQL查询时,可将多条查询语句一起输入,但输出结果在每个命令行的后面,可以将结果放在一起吗?
如:
SELECT   '凈收入: ',SUM(TOTAL_DUE_AMOUNT)
    FROM   BILL.T_BILL_BALANCE_DETAIL_200612
  WHERE   LATN_ID=634   AND   CHARGE_ID   IN   (341110,341120)   AND   STATUS   NOT   LIKE   '9% ';
 
SELECT   '其中168收入: ',SUM(TOTAL_DUE_AMOUNT)
    FROM   BILL.T_BILL_BALANCE_DETAIL_200612
  WHERE   LATN_ID=634   AND   CHARGE_ID   IN   (341120)   AND   STATUS   NOT   LIKE   '9% ';

------解决方案--------------------
SELECT '凈收入: ',SUM(TOTAL_DUE_AMOUNT)
FROM BILL.T_BILL_BALANCE_DETAIL_200612
WHERE LATN_ID=634 AND CHARGE_ID IN (341110,341120) AND STATUS NOT LIKE '9% ';
union
SELECT '其中168收入: ',SUM(TOTAL_DUE_AMOUNT)
FROM BILL.T_BILL_BALANCE_DETAIL_200612
WHERE LATN_ID=634 AND CHARGE_ID IN (341120) AND STATUS NOT LIKE '9% ';