I'm trying to find the following statistic: How many users have made at least one order
(yeah, sounds like homework .. but this is a simplistic example of my real query).
Here's the made up query
SELECT COUNT(UserId)
FROM USERS a
WHERE EXISTS(
SELECT OrderId
FROM ORDERS b
WHERE a.UserId = b.UserId
)
I feel like I'm getting the correct answers but I feel like this is an overkill and is inefficient.
Is there a more efficient way I can get this result?
If this was linq
I feel like I want to use the Any()
keyword....