jsstuff / xql

SQL builder and utilities library for node.js (runs in browser as well).
The Unlicense
20 stars 2 forks source link

OVER() support #9

Open valeeum opened 4 years ago

valeeum commented 4 years ago

Thanks again for this great library!

I'm currently using the following for simple counts over the entire aggregated set.

.FIELD(xql.RAW('count(*) OVER() AS full_count'))

But for more complicated use cases, would be nice not to do this using the RAW method. Here is an example:

  .FIELD(
    COUNT(
      CASE().WHEN(
        AND(...thisPeriodCriteria),
        COL(`sometable.id`),
      ),
    )
      .DISTINCT()
      .OVER()   <-  would be nice if support for this would be added
      .AS('full_count'),
  )