0

我一直在处理以下查询,但无法将其用于 COMPUTE:

BREAK ON "Package ID" SKIP 2 on report
COMPUTE SUM OF "Package Cost" ON "Package ID"
COMPUTE SUM OF "Package Cost" ON REPORT;
Select distinct p.PkgID "Package ID", p.PkgName "Package Type", to_char(p.PkgCost,  '$99.99')"Package Cost", c.CustFName || ' ' || c.CustLName as "Customer Name" 
FROM Subscription s, Package p, Customer c
WHERE p.PkgID = s.PkgID
AND c.CustID = s.CustID     
AND trunc (s.startdate)=to_date('Oct 01, 2012', 'Mon DD, YYYY')
ORDER BY p.PkgID;

输出如下所示:

Package ID Package Type    Package Cost  Customer Name                                                                                                                                                  
---------- --------------- ------------- ---------------------------------------------------                                                                                                            
 10101 Movies Galore    $30.00       Frank Cinatra                                                                                                                                                  
       Movies Galore    $30.00       Krystal Carter                                                                                                                                                 
**********            -------------                                                                                                                                                                


 20202 News Globe       $30.00       Billy Joel                                                                                                                                                     
       News Globe       $30.00       Dia Nelson                                                                                                                                                     
       News Globe       $30.00       Rhonda Shields                                                                                                                                                 
**********            -------------                                                                                                                                                                


 30303 Total Watcher    $40.00       Frank McMann                                                                                                                                                   
       Total Watcher    $40.00       Orlando Magic                                                                                                                                                  
**********            -------------                                                                                                                                                                


 40404 Couch Potato     $50.00       Allan Bubbles                                                                                                                                                  
**********            -------------                                                                                                                                                                


                       -------------               

无法计算成本。它将包裹分解得很好,甚至放在分界线上,只是没有总数。也不会贴标签。我只是错过了一些愚蠢的事情吗?

4

1 回答 1

0

我创建了一个示例表作为您的数据:

PACKAGE_ID PACKAGE_TYPE         PACKAGE_COST C_NAME             
---------- -------------------- ------------ --------------------
     10101 Movies_Galore                  30 Frank_Cinatra        
     10101 Movies_Galore                  30 Krystal_Carter       
     20202 News_Globe                     30 Billy_Joel           
     20202 News_Globe                     30 Dia_Nelson           
     20202 News_Globe                     30 RhondA_Shields       
     30303 Total_Watcher                  40 Frank_McMann         
     30303 Total_Watcher                  40 rlando_Magic         
     40404 Couch_Potato                   50 Allan_Bubbles    

SQL> break on package_id skip 1;
SQL> compute sum label 'package cost' of package_cost on package_id;
SQL> COLUMN package_cost FORMAT $99,99
SQL> select * from test;

PACKAGE_ID PACKAGE_TYPE         PACKAGE_COST C_NAME
---------- -------------------- ------------ --------------------
     10101 Movies_Galore                 $30 Frank_Cinatra
           Movies_Galore                 $30 Krystal_Carter
**********                      ------------
package co                               $60

     20202 News_Globe                    $30 Billy_Joel
           News_Globe                    $30 Dia_Nelson
           News_Globe                    $30 RhondA_Shields
**********                      ------------
package co                               $90


PACKAGE_ID PACKAGE_TYPE         PACKAGE_COST C_NAME
---------- -------------------- ------------ --------------------
     30303 Total_Watcher                 $40 Frank_McMann
           Total_Watcher                 $40 rlando_Magic
**********                      ------------
package co                               $80

     40404 Couch_Potato                  $50 Allan_Bubbles
**********                      ------------
package co                               $50
于 2013-08-23T04:36:59.427 回答