0

Agreement_tran具有列的表Cluster_cd, agreement_date, plot_area. Cluster_cd已查找cluster_dir输入集群的真实名称的位置。我需要的是:

Cluster_name     Plot_area(Today)       Plot_area(To-date)
A                123.654                15468.325
B                542.325                65984.652
C                985.235                56892.326
D                234.784                23697.784

但是下面的代码不起作用,因为它会引发 ORA-911 错误。

SELECT a.cluster_name, 
       (SELECT Sum(plots_area) 
        FROM   agreement_tran b 
        WHERE  b.cluster_cd = a.cluster_cd 
               AND b.agreement_date = '2013-12-22')                        AS 
       today, 
       (SELECT Sum(plots_area) 
        FROM   agreement_tran b 
        WHERE  b.cluster_cd = a.cluster_cd 
               AND b.agreement_date BETWEEN '2013-12-22' AND '2013-12-30') AS 
       todate 
FROM   cluster_dir a; 

我需要cluster_name wise plot_area of​​ today 和to-date 在不同的列中,如上所示。

4

0 回答 0