How to create columns based on columns.
so for row "EOIVR - SB_Internal_LN - 3 - Operator", it would create a column called "operator" and the value would be the value from "option press"
In this sql fiddle
the following table
CREATE TABLE IVRInterval
([cLevelName] varchar(50), [nLevel] FLOAT(20), [I3TimeStampGMT] DATETIME, [cExitPath] varchar(20))
;
INSERT INTO IVRInterval
([cLevelName], [nLevel], [I3TimeStampGMT], [cExitPath])
VALUES
('EOIVR - SB_Internal_LN - 3 - Operator', '5', '2017-10-05 09:30:00.000', 'Workgroup Queue'),
('EOIVR - SB_Internal_LN - 3 - Operator', '5', '2017-10-05 10:00:00.000', 'Workgroup Queue'),
('EOIVR - SB_Internal_LN - 3 - Operator', '5', '2017-10-11 11:30:00.000', 'Workgroup Queue'),
('EOIVR - SB_Internal_LN - 3 - Operator', '5', '2017-10-11 12:30:00.000', 'Workgroup Queue'),
('EOIVR - SB_Internal_LN - 1 - SD', '5', '2017-10-11 13:30:00.000', 'Workgroup Queue'),
('EOIVR - SB_Internal_LN - 1 - SD', '5', '2017-10-09 08:30:00.000', 'Workgroup Queue'),
('EOIVR - SB_Internal_LN - 1 - SD', '5', '2017-10-09 11:00:00.000', '*'),
('EOIVR - SB_Internal_LN - 1 - SD', '5', '2017-10-11 15:00:00.000', 'Workgroup Queue'),
('EOIVR - SB_Internal_LN - 1 - SD', '5', '2017-10-06 09:30:00.000', 'Workgroup Queue'),
('EOIVR - SB_Internal_LN - 1 - SD', '5', '2017-10-06 11:30:00.000', 'Workgroup Queue'),
('EOIVR - SB_Internal_LN - 1 - SD', '5', '2017-10-09 14:30:00.000', '*'),
('EOIVR - SB_Internal_LN - 2 - Lobby', '5', '2017-10-06 13:30:00.000', 'Workgroup Queue'),
('EOIVR - SB_Internal_LN - 2 - Lobby', '5', '2017-10-09 14:00:00.000', 'Workgroup Queue'),
('EOIVR - SB_Internal_LN - 2 - Lobby', '5', '2017-10-04 07:30:00.000', 'Workgroup Queue'),
('EOIVR - SB_Internal_LN - 2 - Lobby', '5', '2017-10-04 08:30:00.000', 'Workgroup Queue'),
('EOIVR - SB_Internal_LN - 2 - Lobby', '5', '2017-10-10 08:00:00.000', '*')
i run this query
select
Convert(date,I3TimeStampGMT) as 'Dates',
(select cLevelName) as 'Options Name',
count(I3TimeStampGMT) as 'Option Press'
from IVRInterval
where
I3TimeStampGMT between '2017-10-04 00:00:00' and '2017-10-11 23:59:59'
and cLevelName like '%%EOIVR - SB_Internal_LN -%%'
and nLevel = '5'
and not cExitPath = '*'
group by cLevelName, Convert(date,I3TimeStampGMT)
I get this result
Dates Options Name Option Press
2017-10-04 EOIVR - SB_Internal_LN - 2 - Lobby 2
2017-10-05 EOIVR - SB_Internal_LN - 3 - Operator 2
2017-10-06 EOIVR - SB_Internal_LN - 1 - SD 2
2017-10-06 EOIVR - SB_Internal_LN - 2 - Lobby 1
2017-10-09 EOIVR - SB_Internal_LN - 1 - SD 1
2017-10-09 EOIVR - SB_Internal_LN - 2 - Lobby 1
2017-10-11 EOIVR - SB_Internal_LN - 1 - SD 2
2017-10-11 EOIVR - SB_Internal_LN - 3 - Operator 2
I would like to have my result like this
Date Lobby SD Operator
2017-10-11 0 1 1
I got read-only on the mssql