使用的是ORACLE 数据库;用PL/SQL developer 写了一些语句,在PL/SQL内能够正常执行出查询结果;但是复制到BOS中提示“SQL测试不通过,请重新检查”;
代码如下:
TRUNCATE TABLE T_O2OORDER_U;
INSERT INTO T_O2OORDER_U ( FSUMSORT, FCUSTID, FONLINECOUNT)
SELECT 0,V1.FCUSTID,COUNT (V1.FID) FROM T_SAL_ORDER V1
WHERE V1.FDATE >=TO_DATE('2015-07-01','YYYY-MM-DD') AND V1.FDATE <=TO_DATE('2015-08-31','YYYY-MM-DD')
AND V1.FID IN (SELECT DISTINCT FID FROM T_SAL_ORDERENTRY_R WHERE FSRCTYPE='CP_SaleOrder')
GROUP BY V1.FCUSTID;
------------------------------------------------------------------------------------------------------
INSERT INTO T_O2OORDER_U (
FSUMSORT,
FCUSTID,
FOFFLINECOUNT
)
SELECT 0,V1.FCUSTID,COUNT (V1.FID) FROM T_SAL_ORDER V1
WHERE V1.FDATE >=TO_DATE('2015-07-01','YYYY-MM-DD') AND V1.FDATE <=TO_DATE('2015-08-31','YYYY-MM-DD')
AND V1.FID NOT IN (SELECT DISTINCT FID FROM T_SAL_ORDERENTRY_R WHERE FSRCTYPE='CP_SaleOrder')
GROUP BY V1.FCUSTID ;
-----------------------------------------------------------------------------------------------------------
INSERT INTO T_O2OORDER_U ( FSUMSORT, FCUSTID, FONLINECOUNT, FOFFLINECOUNT)
SELECT 1,V1.FCUSTID,SUM (V1.FONLINECOUNT),SUM (V1.FOFFLINECOUNT) FROM T_O2OORDER_U V1 GROUP BY V1.FCUSTID ;
DELETE FROM T_O2OORDER_U WHERE FSUMSORT = 0 OR (FONLINECOUNT = 0 AND FOFFLINECOUNT = 0) ;
UPDATE T_O2OORDER_U SET FALLCOUNT = FONLINECOUNT + FOFFLINECOUNT ;
UPDATE T_O2OORDER_U SET FXXBL =ROUND(FOFFLINECOUNT / FALLCOUNT * 100,2);
UPDATE T_O2OORDER_U SET FXSBL =100-FXXBL;
SELECT
V1.FNAME AS 店商名称,
V2.FONLINECOUNT AS 线上订单量,
V2.FOFFLINECOUNT AS 线下订单量,
V2.FALLCOUNT AS 订单总量,
V2.FXXBL AS 线下订单百分比,
V2.FXSBL AS 线上订单百分比
FROM T_BD_CUSTOMER_L V1 INNER JOIN T_O2OORDER_U V2 ON V1.FCUSTID = V2.FCUSTID;
TRUNCATE TABLE T_O2OORDER_U;
推荐阅读