Look at this beautiful consultation guys:

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



El domingo, 15 de octubre de 2017, 0:31:30 (UTC-4), Jeremy Evans escribió:
>
> On Saturday, October 14, 2017 at 8:57:44 PM UTC-7, Carlos Azuaje wrote:
>>
>> Hey, Jeremy.
>>
>> Thank you very much, I was able to successfully complete the query:
>>
>> 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]) # Now, need order by this count desc
>>     .select_append(Sequel[:tags][:name])
>>     .limit(6)
>>     .all
>>
>>
>>
>> Now I am trying to order the records in descending order using counted 
>> tags using group_and_count() 
>>
>
> I think what you want to add to the query above is:
>
>   .reverse{count.function.*}
>
> Thanks,
> Jeremy
>

-- 
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