在第一列的gridview中是一个国家/地区列表。下一列是状态列。在sql我得到它像这样
SELECT COUNT(*) FROM order_customFields
INNER JOIN `order` ON order_customFields.order_id = `order`.order_id
WHERE
order_customFields.order_customFields_delivery_method = 'us' AND
order_customFields.order_customFields_order_date >= '2016-12-01' AND
order_customFields.order_customFields_order_date <= '2016-12-31' AND
`order`.order_status = 'sent'
答案 0 :(得分:1)
SELECT
order_customFields.order_customFields_delivery_method,
sum(case `order`.order_status when 'new' then 1 else 0 end) newtcount,
sum(case `order`.order_status when 'arrived' then 1 else 0 end) arrivedcount,
sum(case `order`.order_status when 'sent' then 1 else 0 end) sentcount
FROM order_customFields
INNER JOIN `order` ON order_customFields.order_id = `order`.order_id
WHERE
order_customFields.order_customFields_order_date >= '2016-12-01' AND
order_customFields.order_customFields_order_date <= '2016-12-31'
GROUP BY
order_customFields.order_customFields_delivery_method,
`order`.order_status