2

これは私のオラクルクエリ..多くの試行が行われましたが、さまざまなエラーが表示されます。

select distinct 
COUNTRY_NAME,                       
TRAN_DATE,
ROUND (nvl(sum(WALKIN_WITHOUT_CGROUP),0)/ COUNT(*),2)APC,
ROUND((nvl(SUM(SALES_VALUE),0)+nvl(sum(total_sales),0)-nvl(sum(net_sales),0)+nvl(sum(discount),0))/nvl(sum(BILLS_WITHOUT_CGROUP),0))ASPB,
ROUND((nvl(SUM(SALES_VALUE),0)+nvl(sum(total_sales),0)-nvl(sum(net_sales),0)+nvl(sum(discount),0))/COUNT(*),2) ASPD,
nvl(sum(BILLS_WITHOUT_CGROUP),0) Bill,
trunc(nvl(SUM(SALES_VALUE),0)+nvl(sum(total_sales),0)-nvl(sum(net_sales),0)+nvl(sum(discount),0)) Sale,
nvl(sum(WALKIN_WITHOUT_CGROUP),0) WALKINS
from OUTLET_PAYMODE_REPORT_FACT A,OUTLET_DETAILS B
WHERE  A.OUTLET_ID=B.OUTLET_ID and SALES_VALUE>0
and rownum <=300
group by COUNTRY_NAME,                      
TRAN_DATE

そして、目的の出力は次のようになります。

MONTH          APC             sale
----- -------           

    01          0      0
    02          0      0
    03          0      0
    04          0      12    
    05          0      14
    06          1       0
    07          1       0
    08          0       0
    09          0       0
    10          2       0
    11          1       0
    12          0       0
4

2 に答える 2

1

selectステートメントの列の間にコンマを入れる必要があります

    select '01', to_char(tran_date,'mm') from OUTLET_PAYMODE_REPORT_FACT A,OUTLET_DETAILS B union all
select '02', to_char(tran_date,'mm') from OUTLET_PAYMODE_REPORT_FACT A,OUTLET_DETAILS B union all
select '03', to_char(tran_date,'mm') from OUTLET_PAYMODE_REPORT_FACT A,OUTLET_DETAILS B union all
select '04', to_char(tran_date,'mm') from OUTLET_PAYMODE_REPORT_FACT A,OUTLET_DETAILS B union all
select '05', to_char(tran_date,'mm') from OUTLET_PAYMODE_REPORT_FACT A,OUTLET_DETAILS B union all
select '06', to_char(tran_date,'mm') from OUTLET_PAYMODE_REPORT_FACT A,OUTLET_DETAILS B union all
select '07', to_char(tran_date,'mm') from OUTLET_PAYMODE_REPORT_FACT A,OUTLET_DETAILS B union all
select '08', to_char(tran_date,'mm') from OUTLET_PAYMODE_REPORT_FACT A,OUTLET_DETAILS B union all
select '09', to_char(tran_date,'mm') from OUTLET_PAYMODE_REPORT_FACT A,OUTLET_DETAILS B union all
select '10', to_char(tran_date,'mm') from OUTLET_PAYMODE_REPORT_FACT A,OUTLET_DETAILS B union all
select '11', to_char(tran_date,'mm') from OUTLET_PAYMODE_REPORT_FACT A,OUTLET_DETAILS B union all
select '12', to_char(tran_date,'mm') from OUTLET_PAYMODE_REPORT_FACT
于 2013-08-27T07:51:08.513 に答える