On Wednesday, September 26, 2018 at 8:37:50 AM UTC-7, Harlow wrote:
>
> i'm trying to select the first element from an array_agg function:
> https://www.postgresql.org/docs/9.5/static/functions-aggregate.html
>
> The issue is i'm having trouble figuring out where to put the `[1]` when 
> using Sequel
>
> For example i'd like the first value of the array:
>
> array_agg(ids)[1] as id
>
>
> However in in Sequel I'm not sure how to get the first element:
>
> Sequel.function(:array_agg, ids).as(:id) # => this is array
>
>
> Is there a Sequel syntax for `[1]`?
>

Sequel.function(:array_agg, ids).sql_subscript(1).as(:id)

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 sequel-talk+unsubscr...@googlegroups.com.
To post to this group, send email to sequel-talk@googlegroups.com.
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