Something along the lines of this...first I'd combine your conference size queries into one view:
-- Or maybe conf_size_counts ??
CREATE VIEW conf_sizes AS
SELECT
c2.id,
sum(if(value<11,1,0)) AS "conf10",
sum(if(value<20 and value>10,1,0)) AS "conf20",
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.id;
Then modify your main query as:
SELECT c.id, c.name, cs.conf10, cs.conf20, cs.conf30
FROM client c LEFT OUTER JOIN conf_sizes cs ON c.id = cs.id
WHERE c.level = 50
AND c.status = 1
The rest of the views and joins I leave for you...
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.