Sunday, 15 June 2014

mysql - SQL: count() and avg() functions -



mysql - SQL: count() and avg() functions -

i have problem 2 sql functions. need utilize count(), in case count greater 1 want utilize avg() function average price. wrote query , doesn't work, solutions ?

select avg( ΚΟΣΤΟΣ ) priceaverage ΔΡΟΜΟΛΟΓΙΟ ( select count( ΑΦΕΤΗΡΙΑ ) count ΔΡΟΜΟΛΟΓΙΟ ΑΦΕΤΗΡΙΑ = 'ath' ) > 1 )

thanks in advance

filter on aggregates in having clause.

select avg(ΚΟΣΤΟΣ) priceaverage ΔΡΟΜΟΛΟΓΙΟ ΑΦΕΤΗΡΙΑ = 'ath' having count(*) > 1

mysql sql

No comments:

Post a Comment