有兩個sql查詢,我想寫爲一個查詢。 第二個查詢顯示action_text類似'%STAFF%'的不同記錄的計數。 我試過使用聯盟,但它沒有奏效。兩個sql查詢爲一個
select date(dated) date_ord,
count(DISTINCT order_number) as orders_placed,
sum(case when action_text like '%STAFF%' then 1 else 0 end) AS orders_staff,
sum(case when action_text in (
'CBA Capture attempt',
'GCO Capture attempt',
'PPP Capture',
'PPE Capture',
'Staff CC capture',
'Web CC capture',
'Staff Finance WIRE authorized',
'Staff Finance PO authorized',
'Staff Finance COD authorized',
'Authorized The CPIC') then 1 else 0 end) AS orders_manuallycaptured
from stats.sales_actions
group by date_ord
order by dated desc
SELECT COUNT(DISTINCT order_number) as unique_orderstouched,
date(dated) date_ords
FROM sales_actions
WHERE action_text like '%STAFF%'
group by date_ords
order by dated desc
日期 訂單 的訂單 感動訂單手動 捕獲獨特訂單 觸摸 2012-02-03 329 162 77 135 2012-02-02 299 148 70 122 2012-02-01 340 169 102 156 2012-01-31 271 143 78 126 2012 -01-30 436 211 129 187 2012-01-27 275 138 66 112 2012-01-26 318 150 87 128 2012-01-25 297 145 91 152 2012-01-24 163 77 60 87 – rachel 2012-02-07 06:29:06
謝謝:)它的工作..有一個美好的一天 – rachel 2012-02-07 07:22:57