Hi Guys, I have this query below: It works fine however i'd like to use
Where t2.NumberOFMeeting = 'Not visited' in the where clause instead of:
where t2.NumberOFMeeting is null
any help would be appreciated
Declare @Year varchar(4) = 2010, @Quarter varchar(9) = null, @Month varchar(3) = null
Select t1.AccountName, Case when ISNull(t2.NumberOFMeeting,0) = 0
THEN 'Not Vistited' else 'Visited' End As NumberOfMeetings
From
(Select AccountName
From Sales_Matrix
where [YEAR] = @Year
and (@Quarter Is Null Or Quarter_Name = @Quarter)
and (@Month Is NULL or [MONTH] = @Month)
Group By AccountName)t1 left outer join (Select MaginusAccount, Count(MaginusAccount) As NumberOFMeeting
From V_TimeCard
where [YEAR] = @Year
and (@Quarter Is Null Or [Quarter] = @Quarter)
and (@Month Is NULL or [MONTH] = @Month)
Group by MaginusAccount) t2 on t1.AccountName = t2.MaginusAccount
Where t2.NumberOFMeeting is null
Where t2.NumberOFMeeting = 'Not visited' in the where clause instead of:
where t2.NumberOFMeeting is null
any help would be appreciated
Declare @Year varchar(4) = 2010, @Quarter varchar(9) = null, @Month varchar(3) = null
Select t1.AccountName, Case when ISNull(t2.NumberOFMeeting,0) = 0
THEN 'Not Vistited' else 'Visited' End As NumberOfMeetings
From
(Select AccountName
From Sales_Matrix
where [YEAR] = @Year
and (@Quarter Is Null Or Quarter_Name = @Quarter)
and (@Month Is NULL or [MONTH] = @Month)
Group By AccountName)t1 left outer join (Select MaginusAccount, Count(MaginusAccount) As NumberOFMeeting
From V_TimeCard
where [YEAR] = @Year
and (@Quarter Is Null Or [Quarter] = @Quarter)
and (@Month Is NULL or [MONTH] = @Month)
Group by MaginusAccount) t2 on t1.AccountName = t2.MaginusAccount
Where t2.NumberOFMeeting is null