[SQL] 纯文本查看 复制代码 SELECT
ROUND(SUM(CASE
WHEN XF_TXDATE BETWEEN TRUNC(SYSDATE) AND TRUNC(SYSDATE) THEN XF_AMTSOLD
ELSE 0
END) / 10000, 10) AS today_total_sales,
ROUND((SUM(CASE
WHEN XF_TXDATE BETWEEN TRUNC(SYSDATE) AND TRUNC(SYSDATE) THEN XF_AMTSOLD
ELSE 0
END) - SUM(CASE
WHEN XF_TXDATE BETWEEN TRUNC(SYSDATE) AND TRUNC(SYSDATE) THEN XF_MALLBEARCOUPONAMOUNT
ELSE 0
END) - SUM(CASE
WHEN XF_TXDATE BETWEEN TRUNC(SYSDATE) AND TRUNC(SYSDATE) THEN XF_STOREBEARCOUPONAMOUNT
ELSE 0
END)) / 10000, 10) AS today_net_sales,
ROUND(SUM(CASE
WHEN XF_TXDATE BETWEEN TRUNC(SYSDATE, 'MM') AND TRUNC(SYSDATE) THEN XF_AMTSOLD
ELSE 0
END) / 10000, 10) AS month_total_sales,
ROUND((SUM(CASE
WHEN XF_TXDATE BETWEEN TRUNC(SYSDATE, 'MM') AND TRUNC(SYSDATE) THEN XF_AMTSOLD
ELSE 0
END) - SUM(CASE
WHEN XF_TXDATE BETWEEN TRUNC(SYSDATE, 'MM') AND TRUNC(SYSDATE) THEN XF_MALLBEARCOUPONAMOUNT
ELSE 0
END) - SUM(CASE
WHEN XF_TXDATE BETWEEN TRUNC(SYSDATE, 'MM') AND TRUNC(SYSDATE) THEN XF_STOREBEARCOUPONAMOUNT
ELSE 0
END)) / 10000, 10) AS month_net_sales,
ROUND(SUM(CASE
WHEN XF_TXDATE BETWEEN TO_DATE('2023-01-01', 'YYYY-MM-DD') AND TRUNC(SYSDATE) THEN XF_AMTSOLD
ELSE 0
END) / 10000, 10) AS year_total_sales,
ROUND((SUM(CASE
WHEN XF_TXDATE BETWEEN TO_DATE('2023-01-01', 'YYYY-MM-DD') AND TRUNC(SYSDATE) THEN XF_AMTSOLD
ELSE 0
END) - SUM(CASE
WHEN XF_TXDATE BETWEEN TO_DATE('2023-01-01', 'YYYY-MM-DD') AND TRUNC(SYSDATE) THEN XF_MALLBEARCOUPONAMOUNT
ELSE 0
END) - SUM(CASE
WHEN XF_TXDATE BETWEEN TO_DATE('2023-01-01', 'YYYY-MM-DD') AND TRUNC(SYSDATE) THEN XF_STOREBEARCOUPONAMOUNT
ELSE 0
END)) / 10000, 10) AS year_net_sales
FROM
xf_transsalesitem t, xf_mdcontracth m
WHERE
t.xf_storecode = m.xf_contractno
AND XF_BUSINESSTYPE = 5;
|