1
我與此查詢工作:加入總一行總和計數
SELECT PAS.NAME,
(
SELECT COUNT(*) FROM CUSOMERS WHERE C_ID = 90
AND CONTRACT_TYPE = 80
AND CONTRACT_DATE >= TO_DATE('20160101', 'YYYYMMDD')
AND CONTRACT_DATE <= TO_DATE('20161231', 'YYYYMMDD')
AND ORDER_ID = ORDERS.ID
AND STATUS = 1
) AS ORDER_SHIPPED_COUNT FROM ORDERS INNER JOIN PAS ON ORDERS.ID = PAS.ID
WHERE ORDERS.COUNTRY = 123
AND ORDERS.PAYMENT = 30
AND ORDERS.CONTRACT_TYPE = 80
AND PAS.NAME LIKE 'HAS SHIPPED - %';
結果我得到的是以下幾點:
NAME ORDER_SHIPPER_COUNT
HAS SHIPPED ON TIME 654
HAS SHIPPED LATE 23
HAS SHIPPED AND LOST 2
而且我想結果是這樣
NAME ORDER_SHIPPER_COUNT
HAS SHIPPED ON TIME 654
HAS SHIPPED LATE 23
HAS SHIPPED AND LOST 2
TOTAL 679
感謝所有
謝謝!!它的工作 – Chrix1387
你可以檢查第二個查詢,如果它也適用於你。 – hemalp108