I have a MySQL table where all the company sales for a given period are grouped by unit, date and, inside an array, all the sales representatives IDs that were involved in each sale. The first sales_rep ID in each array shows which sales representative was responsible for closing each sale. I am trying to elaborate a query that returns the unit, the date and the sales_rep ID for each sales representative that closed each sale. It is ok if a sales_rep ID is shown more than once for given date.
What I have as input:
unit_id date unit_sales sales_reps
427 2019-07-01 3 [["19823508","19823510",""],["23661230","23661227","23411261",""],["23411257","19823508",""]]
466 2019-07-26 2 [["23222763","23222766","26726848","26726849",""],["23222763",""]]
The desired output is:
unit_id date sales_rep
427 2019-07-01 19823508
427 2019-07-01 23661230
427 2019-07-01 23411257
466 2019-07-26 23222763
466 2019-07-26 23222763