The final query:

Is beatiful

query = DB[:users]
    .join(:snippets, user_id: :id)
    .join(:snippets_tags, snippet_id: :id)
    .join(:tags, id: :tag_id)
    .where {
        Sequel.&(
          {:user_id=>user.id},
          {Sequel[:tags][:description]=>'language'}
        )
    }
    .group_and_count(Sequel[:tags][:id])
    .order(:count).reverse
    .select_append(Sequel[:tags][:name])
    .limit(6)
    .all

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to