这是我的 oracle 查询..我尝试了很多,但它显示不同的错误我的条件是显示 12 个月,如果没有数据显示 0 值,如果数据只显示值.....
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