我有一个头计数(voucher_credits.voucher_id),我已经使用WHERE语句将其添加到我的报告中,但我想再次添加它作为另一列使用不同的标准,我该怎么做?SQL使用相同的字段两次以不同的标准
SELECT vouchers.code, vouchers.credit, count(voucher_credits.voucher_id) as Activated
FROM vouchers, voucher_credits, users
WHERE vouchers.id = voucher_credits.voucher_id
AND voucher_credits.remaining_credit = 0
AND users.id = voucher_credits.user_id AND users.state = 'active'
AND vouchers.is_customer_service = FALSE
GROUP by vouchers.code, vouchers.credit
ORDER by count(voucher_credits.voucher_id) DESC
LIMIT 100
第二列是users.state = '取消',不.remaining_credit = 0