I have a report that uses a multiselect option to retrieve some input from my users. For each option they have selected I would like to run a count(*) on it and return the result. Right now it will perform the count for every single option together and display it as one result, but I would like one result per option selected, and with a total row if possible also. Is this able to be done? I looked through the documentation but it doesn't look like myDBR has any built in for loops and MySQL is only able to do it via a cursor.
My report code is:
CREATE PROCEDURE `sp_DBR_LeadInsertionCounts`(vStartDate datetime, vEndDate datetime, inLists text)
SELECT count(*) AS 'Lead Count' FROM asterisk.vicidial_list WHERE find_in_set(list_id, inLists) AND entry_date BETWEEN vStartDate and vEndDate;
And the procedure that generates the options is:
CREATE PROCEDURE `sp_DBR_SelectLists`(inLists varchar(255))
select list_id, concat(list_id, " - ", list_name) from asterisk.vicidial_lists where list_id like concat('%', inLists, '%') limit 40;