'Is there another way to write SUM(IIF([CONDITION], 1, 0))?
What SUM(IIF([CONDITION], 1, 0))
does is very simple. So simple, that what I really just want to write is COUNT([CONDITION])
(but that's invalid). Is there a shorter or more preferred way to write SUM(IIF([CONDITION], 1, 0))
?
Solution 1:[1]
You should be able to move your condition to where clause.
Select count(*) from [table(s)] where [CONDITION];
The above only counts where the condition that results in a match. You will find that providing a query example will go a long way in finding a solution.
Best of luck.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Max |