sql distinct selection avg aggregate -


here table schema

img http://i58.tinypic.com/2qkihqp.png

sessionid , relevancy not unique

i want remove urlid duplicates , have avg of relevancy values corresponding of each unique urlid.

this code

select distinct urlid,avg (relevancy) ccc  group urlid,relevancy 

my result

img http://i57.tinypic.com/2z67bb9.png

for example want have urlid=15030753 (2+0)/2=1

urlid         avg  ...          ... 15030753      1 ...           ... 

drop relevancy in group by clause, if want aggregate on it. can drop distinct there 1 urlid entry due group by.

select urlid,avg (relevancy) ccc  group urlid 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -