I have the following query:
(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);
I had to make this union cause I need both entry_type and outcome counts to be on the following chart.
From Call to Follow Up Contact I get from the 'entry_type' and the rest from outcomes.
Thing is, I need to sort this so New Appointment Booked ( an outcome ) show right after Walk In, No interest after that and you got the idea...
I tried the following (and some other stuff before that) for testing purposes...
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);
No success.
Any ideas on how to approach this?