我希望输出显示交易和状态的数量。如果相同的数字已成功完成交易(状态= 0),即使相同的数字已经进行了一些交易,也会计为1。
SELECT CAST(t.DATE AS DATE) AS DATE
,(t.TRANSACTION + r.Request) AS allTransaction
,(t.Success + r.RequestSuccess) AS allSuccess
,t.TRANSACTION
,t.Success
,r.Request
,r.RequestSuccess
FROM (
SELECT DATE
,count(DISTINCT no_a) AS TRANSACTION
,count(t.STATUS) AS Success
FROM transfer_tx_201503 AS t
WHERE STATUS = 0
AND cast(DATE AS TIME) BETWEEN "00:00:00"
AND "15:00:00"
GROUP BY CAST(DATE AS DATE)
) AS t
JOIN (
SELECT DATE
,count(DISTINCT no_a) AS Request
,count(r.STATUS) AS RequestSuccess
FROM request_tx_201503 AS r
WHERE STATUS = 0
GROUP BY CAST(DATE AS DATE)
) AS r ON CAST(t.DATE AS DATE) = CAST(r.DATE AS DATE)
GROUP BY DATE DESC;