untested but...

If i where to write raw SQL, i think this is what you are asking for (where 
auth.user.id==42):

SELECT ut.user, count(*) 
FROM users_tags ut 
WHERE ut.user != 42 
  AND ut.tag IN (SELECT tag FROM user_tags WHERE user=42)
GROUP BY ut.user
ORDER BY count(*)


and i think this translated to DAL is:

count = db.user_tags.id.count()

query = db((db.user_tags.user != auth.user.id) &
          
 (db.user_tags.tag.belongs(db(db.user_tags.user==auth.user.id)._select())))

rows = query.select(db.user_tags.user,
                    count,
                    groupby=db.user_tags.user,
                    orderby=count)


as i said, untested, but following similar logic i had written before.

christian 

Reply via email to