How to use an Alias in a Calculation for Another Field
That method doesn’t work in SQL Server. You can accomplish the same thing in a couple different ways: 1.) Use the code for each aliased column instead of the alias: (SELECT COUNT(*) FROM UserEvent UE WHERE UE.EventTypeID = 1 AND UE.PracticeID = au.PracticeID AND (UE.EventDate BETWEEN @Date1 and @Date2) – COUNT(CASE WHEN udi.DevicePlatform = ‘iOS’ … Read more