I have the below SQL statement. The column wrapupcode can be up to four values:
Sales, Service, Meeting, Other
When the SQL is run, the column wrapupcode is showing as a single column. What I would like to work out, is to dynamically create a new wrapupcode based on the value. We may added or remove the codes, otherwise I would case for the value.
This is based on a MySQL database.
Data currently looks like:
user wrapupcode intialtime endofwrapup timediff
joe Service 11:38 11:39 1
jenny Sales 11:35 11:36 1
joe Service 11:41 11:42 1
But would like to see if its possible via SQL on a MySQL database:
user Service Sales timediff
joe 2 2
jenny 1 1
I can do the sum/avg for the times and totals, its just adding a new column on each different wrapupcode.
SELECT
( SELECT loginid FROM `axpuser` WHERE age.userid = axpuser.pkey ) as user,
( SELECT name FROM `breakcode` WHERE age.wrapupcode = pkey ) as wrapupcode,
time(age.`instime`) as initialtime,
age.`ENDOFWRAPUPTIME` AS endofwrapup,
timediff(age.`ENDOFWRAPUPTIME`, time(age.`instime`)) as timediff
FROM
agentcallinformation age
WHERE
age.endofwrapuptime IS NOT null and ( SELECT name FROM `breakcode` WHERE age.wrapupcode = pkey ) <> ''