我有以下查询:
(SELECT entry_type AS action, count(entries.type_id) as total
FROM entries
LEFT JOIN type ON entries.type_id = type.type_id
GROUP BY entry_type)
UNION
(SELECT outcome AS action, count(entries.out_id) as total
FROM entries
LEFT JOIN outcomes ON entries.out_id = outcomes.out_id
GROUP BY outcome);
我必须建立这个联盟,因为我需要entry_type和结果计数在下面的图表上。
从通话到跟进联系我来自' entry_type'其余来自结果。
事情是,我需要对此进行排序,以便在Walk In之后立即预约(结果)显示,之后没有兴趣并且您有了这个想法......
为了测试目的,我尝试了以下(以及之前的其他一些内容)......
SELECT * FROM (
(SELECT entry_type AS action, count(entries.type_id) as total
FROM entries
LEFT JOIN type ON entries.type_id = type.type_id
GROUP BY entry_type) UNION
(SELECT outcome AS action, count(entries.out_id) as total
FROM entries
LEFT JOIN outcomes ON entries.out_id = outcomes.out_id
GROUP BY outcome)) AS u
ORDER BY FIELD(type_id, 2,1);
没有成功。
有关如何处理此事的任何想法?