I have a query:
select AVG(tickets_number)
from TABLE_ONE
where ofd_id = :ofdId and launch_id in
(select id from TABLE_TWO where is_actual = 1 and is_matching_completed = 1)
But I need to calculate average value only if there are at least 10 rows from this query, otherwise I have to return NULL.
How can I do this?
CodePudding user response:
Try this case expression.
select CASE WHEN COUNT(tickets_number) >= 10
THEN AVG(tickets_number)
ELSE NULL END average
from TABLE_ONE ...