It might be possible, and I did start down that road, but the query got pretty scary. I think I'm more comfortable with multiple queries, but maybe I'm wrong. Here are all the queries, the first generates the client list, the rest populate the integer fields:
SELECT c2.id, c2.name as 'client' FROM client c2 WHERE level = 50 and status = 1; SELECT c2.id, c2.name as 'client', count(*) as 'ext' FROM client c1, client c2 WHERE c1.level=100 AND c1.status=1 AND ext.type = "phone" AND c1.parent_client_id = c2.id GROUP BY c1.parent_client_id ORDER BY c2.name; SELECT c2,id, c2.name as 'client', count(*) as 'vm' FROM extension ext, client c1, client c2, extension_prefs exp WHERE ext.client_id = c1.id AND c1.level=100 AND exp.param="voicemail" AND exp.value=1 AND c1.parent_client_id = c2.id AND exp.extension_id = ext.id GROUP BY c2.name; SELECT c2.id, c2.name as 'client', count(*) as 'ivr' FROM extension ext, client c1, client c2 WHERE ext.client_id = c1.id AND ext.type = 'ivr' AND c1.status = 1 AND c1.parent_client_id = c2.id GROUP BY c2.name; SELECT c2.id, c2.name as 'client', count(*) as 'queues' FROM extension ext, client c1, client c2 WHERE ext.client_id = c1.id AND ext.type = 'queue' AND c1.status = 1 AND c1.parent_client_id = c2.id GROUP BY c2.name; SELECT c2.id, c2.name as 'client', sum(if(value<11,1,0)) AS "conf10" FROM extension ext, client c1, client c2, extension_prefs exp WHERE ext.client_id = c1.id AND exp.param="conf_size" AND ext.type="conference" AND c1.parent_client_id = c2.id AND exp.extension_id = ext.id GROUP BY c2.name; SELECT c2.id, c2.name as 'client', sum(if(value<20 AND value>10,1,0)) AS "conf20" FROM extension ext, client c1, client c2, extension_prefs exp WHERE ext.client_id = c1.id AND exp.param="conf_size" AND ext.type="conference" AND c1.parent_client_id = c2.id AND exp.extension_id = ext.id GROUP BY c2.name; SELECT c2.id, c2.name as 'client', sum(if(value>20,1,0)) AS "conf30" FROM extension ext, client c1, client c2, extension_prefs exp WHERE ext.client_id = c1.id AND exp.param="conf_size" AND ext.type="conference" AND c1.parent_client_id = c2.id AND exp.extension_id = ext.id GROUP BY c2.name;
In reply to Re^2: Help with MySQL SELECT into multidimensional array
by btongeorge
in thread Help with MySQL SELECT into multidimensional array
by btongeorge
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |