AME
AME

Reputation: 2302

Sql with window function to JOOQ

I have this query:

SELECT id, url, name, email, count(*) OVER() AS overallCount 
FROM images 
WHERE email = ? 
OFFSET ? 
LIMIT ?

I'd like to translate it into JOOQ, how could I achieve that?

Upvotes: 0

Views: 119

Answers (1)

Lukas Eder
Lukas Eder

Reputation: 221031

Assuming this static import

import static org.jooq.impl.DSL.*;

And then

String email = ...
int offset = ...
int limit = ...

using(configuration)
  .select(
    IMAGES.ID,
    IMAGES.URL,
    IMAGES.EMAIL,
    count().over().as("overallCount"))
  .from(IMAGES)
  .where(IMAGES.EMAIL.eq(email))
  .offset(offset)
  .limit(limit)
  .fetch();

Upvotes: 1

Related Questions