Reputation: 1
I'm working on a SQL code for my work, so I will make the question general.
When I use a count function, in my having clause, I've set the condition as
COUNT(ED.TRANSACTION_KEY) > QP.MIN_OCCURRENCES.
I've passed both ED and QP tables. It seems if I change the condition to COUNT(ED.TRANSACTION_KEY) > 3
, the code works. However, once I set the conditions based on two parameters, the system shows "not a GROUP BY expression". Please advice.
Upvotes: 0
Views: 82
Reputation: 1270773
You need to either use an aggregation function:
HAVING COUNT(ED.TRANSACTION_KEY) > MIN(QP.MIN_OCCURRENCES)
or move QP.MIN_OCCURRENCES
to the GROUP BY
clause.
Upvotes: 1