Last active
August 31, 2021 04:33
-
-
Save henninb/105c26dead2dbbfd92318ce00af02883 to your computer and use it in GitHub Desktop.
Jooq.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Field TOTALS_DEBITS = dslContext.select(DSL.coalesce(DSL.sum(T_TRANSACTION.AMOUNT), 0.0).as("debits")) | |
.from(T_TRANSACTION) | |
.where(T_TRANSACTION.ACTIVE_STATUS.eq(true) & T_TRANSACTION.ACCOUNT_TYPE.eq("debit")).asField() | |
Field TOTALS_CREDITS = dslContext.select(DSL.coalesce(DSL.sum(T_TRANSACTION.AMOUNT), 0.0).as("credits")) | |
.from(T_TRANSACTION) | |
.where(T_TRANSACTION.ACTIVE_STATUS.eq(true) & T_TRANSACTION.ACCOUNT_TYPE.eq("credit")).asField() | |
return dslContext.select((TOTALS_DEBITS - TOTALS_CREDITS).as("totals")) | |
.fetchOneInto(Summary) |
@lukaseder I got it working with the code above. Thank you so much for walking through my struggles with me.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@lukaseder thanks again for your time and assistance.
When I remove the
.asField("debits")
and.asField("credits")
, I am not allowed to subtract the 2 fields because they are of typeSelectConditionStep
. I assume I want these variables to be of typeField
so I can subtract them?