On Friday, December 18, 2015 at 7:16:27 AM UTC-8, amar nath wrote:
>
> Hi,
>
>       I am having a scenario where I need to use array_agg function to 
> group the results and also use order by to sort the result. 
>       In sql I can write this in my statement:
>       "array_agg(users.salary order by  users.id desc) as salaries"
>
>       When I convert this statement into Sequel I am able to group the 
> users but I am not able to sort the result.
>       I have refereed your documentation but I did not found any method to 
> solve my problem.  
>       "array_agg(:users__salary).as(:salaries)"
>
>       Can you guys help me in solving this Where I can use order by in 
> array_agg .
>
>       Thanks. 
>

Sequel doesn't support this SQL syntax natively, you'll have to use raw SQL:

   array_agg(Sequel.lit('users.salary ORDER BY users.id 
DESC')).as(:salaries)

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