In my table I have some colms like this, (beside another cols)
col1 | col2
s1   |  5
s1   |  5
s2   |  3
s2   |  3
s2   |  3
s3   |  5
s3   |  5
s4   |  7
I want to have average of ALL col2 over Distinct col1. (5+3+5+7)/4=5
Try this:
SELECT AVG(T.col2)
FROM 
    (SELECT DISTINCT col1, col2
    FROM yourtable) as T
                        You are going to need a subquery. Here is one way:
select avg(col2)
from (select distinct col1, col2
      from my_table
     ) t
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With