Can you help me with this GOTO statement
Declare @Year varchar(4) = '2010', @Quarter varchar(9) = null, @Month varchar(3) = Null
If @Quarter = null and @Month = null GOTO Step_One; Else GOTO Step_Four;
Step_One:
SELECT 'StepOne', CASE Targeted_Account
WHEN 'TRUE' THEN 'Targeted' ELSE 'Un-Targeted' END AS [Customer Type],
COUNT(DISTINCT MaginusAccount) AS [Resellers]
FROM dbo.V_TimeCard
where [YEAR] = @Year
GROUP BY Targeted_Account
Step_Four:
SELECT 'StepOne', CASE Targeted_Account
WHEN 'TRUE' THEN 'Targeted' ELSE 'Un-Targeted' END AS [Customer Type],
COUNT(DISTINCT MaginusAccount) AS [Resellers]
FROM dbo.V_TimeCard
where [YEAR] = @Year and [Quarter] = @Quarter and [MONTH] = @Month
GROUP BY Targeted_Account
Can you tell me why this executes both queries? although im only passing in one parameter...
Any help would be greatful
Declare @Year varchar(4) = '2010', @Quarter varchar(9) = null, @Month varchar(3) = Null
If @Quarter = null and @Month = null GOTO Step_One; Else GOTO Step_Four;
Step_One:
SELECT 'StepOne', CASE Targeted_Account
WHEN 'TRUE' THEN 'Targeted' ELSE 'Un-Targeted' END AS [Customer Type],
COUNT(DISTINCT MaginusAccount) AS [Resellers]
FROM dbo.V_TimeCard
where [YEAR] = @Year
GROUP BY Targeted_Account
Step_Four:
SELECT 'StepOne', CASE Targeted_Account
WHEN 'TRUE' THEN 'Targeted' ELSE 'Un-Targeted' END AS [Customer Type],
COUNT(DISTINCT MaginusAccount) AS [Resellers]
FROM dbo.V_TimeCard
where [YEAR] = @Year and [Quarter] = @Quarter and [MONTH] = @Month
GROUP BY Targeted_Account
Can you tell me why this executes both queries? although im only passing in one parameter...
Any help would be greatful