Hello,
I have a crosstab report where I am pulling contact attempt counts of a list of customers and displaying them in order of the contact list they came from. I want to make it so where any attempt count over 25 gets rolled into a single column called "Over 25" or something similar. I was able to pull this manually by running a second SELECT but it caused the result to appear below the crosstab as opposed to another column on the end of it. Is there a way to have this column appended or perhaps use some calculation function which grabs all columns over 25 and adds them up? Report code is below.
DROP PROCEDURE IF EXISTS sp_DBR_CalledCountsCampaign
$$
CREATE PROCEDURE `sp_DBR_CalledCountsCampaign`()
BEGIN SELECT 'dbr.hdr', '[list]';
SELECT 'dbr.sum', '[lcount]';
SELECT 'dbr.summary.options', 'limit_summary_level', '1';
SELECT 'dbr.summary.text', '[list]', 'Totals'; SELECT 'dbr.crosstab', '[ccount]'; SELECT CONCAT(v.list_id, " - ", asterisk.vicidial_lists.list_name) as 'List[list]',
v.called_count as 'Called Count[ccount]',
count(*) as '[lcount]'
FROM asterisk.vicidial_list v
LEFT JOIN asterisk.vicidial_lists ON v.list_id = asterisk.vicidial_lists.list_id
WHERE v.list_id = '1003'
GROUP BY v.list_id, v.called_count
ORDER BY v.called_count asc; END
$$