On Friday, January 4, 2013 3:17:29 AM UTC-8, [email protected] wrote:
>
> Hi all (and happy new year!)
>
> I'm a sequel noob and have been banging my head against a wall trying to 
> get sequel to produce 
> the following query:
>
>    SELECT *, COUNT(*) OVER() AS fullcount FROM "table" ...
>

Anytime you want to produce SQL and can't figure out how to get Sequel to 
produce it, you can use a literal string:

  DB[:table].select(Sequel.lit("*, COUNT(*) OVER() AS fullcount"))

That being said, Sequel has DSL support for what you want via virtual rows:

  DB[:table].select_append{count(:over, :* => true){}.as(:fullcount)}
 

> The "COUNT(*) OVER() AS fullcount" is a postgresism that allows one to get 
> the total number
> of results ignoring a subsequent LIMIT; I need this for a pagination query.
>

BTW, it's not a postgresism, it's a standard SQL window function.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/6TidokG4Zt8J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to