我正在尝试以下查询,它可以正常工作,但是有什么方法可以减少它?
<?php
$c_qr="
SELECT count(profit) AS 'y_c'
,profit AS 'x_c'
FROM account
WHERE profit = 'excellent'
UNION
SELECT count(profit) AS 'c1'
,profit AS 'c2'
FROM account
WHERE profit = 'fair'
UNION
SELECT count(profit) AS 'c1'
,profit AS 'c2'
FROM account
WHERE profit = 'bad'
UNION
SELECT count(sale) AS 'c1'
,sale AS 'c2'
FROM account
WHERE sale = 'excellent'
UNION
SELECT count(sale) AS 'c1'
,sale AS 'c2'
FROM account
WHERE sale = 'fair'
UNION
SELECT count(sale) AS 'c1'
,sale AS 'c2'
FROM account
WHERE sale = 'bad'
UNION
SELECT count(purchase) AS 'c1'
,purchase AS 'c2'
FROM account
WHERE purchase = 'excellent'
UNION
SELECT count(purchase) AS 'c1'
,purchase AS 'c2'
FROM account
WHERE purchase = 'fair'
UNION
SELECT count(purchase) AS 'c1'
,sale AS 'c2'
FROM account
WHERE purchase = 'bad'
";