I am using SSMS 2019 and Report builder to make reports, MY problem is in this query it does not accept AS
SELECT Country,ServiceGrade as BestCenter from VW_FactCallCenter
WHERE EXISTS(SELECT DISTINCT Country, MAX(ServiceGrade) as MaxGrade FROM VW_FactCallCenter GROUP BY Country) AS BestCenter
With this Query I get my desired Result, But when I add subquery to it, I cant use 2 column, when I use With Exists
then I cant use Alias
SELECT DISTINCT Country, MAX(ServiceGrade) as MaxGrade FROM VW_FactCallCenter GROUP BY Country
This is my DDL
CREATE view VW_FactCallCenter (IssuesRaised Smallint,
LevelOneOperators Smallint,
LevelTwoOperators Smallint,
ServiceGrade Float,
Shift Nvarchar(20),
Date Datetime,
TotalOperators Smallint,
Country Varchar(7) )
INSERT into VW_FactCallCenter (IssuesRaised,
LevelOneOperators ,
LevelTwoOperators ,
ServiceGrade ,
Shift,
Date ,
TotalOperators,
Country ) VALUES (1,1,4,0.12,'midnight','2014-05-05',5,'Italy');
INSERT into VW_FactCallCenter (IssuesRaised,
LevelOneOperators ,
LevelTwoOperators ,
ServiceGrade ,
Shift,
Date ,
TotalOperators,
Country ) VALUES (2,2,7,0.18,'AM','2014-08-12',9,'France');
INSERT into VW_FactCallCenter (IssuesRaised,
LevelOneOperators ,
LevelTwoOperators ,
ServiceGrade ,
Shift,
Date ,
TotalOperators,
Country ) VALUES (4,5,7,0.21,'AM','2014-09-12',12,'Germany');
My goal is to compare Call Centers depending on Country as you can see in the Desired Result image, I am thinking to use Concat but without using that is there a way to do it? Unfortunately I have been asking this problem to my supervisor but he seems so busy so I need help, I have been trying to solve this problem since yesterday I have tried other methods but I really want to use Alias for a report in my subquery