Jump to content

My first ExecSQL Join


This topic is 3056 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Quite simply can anyone point out what is wrong with this?

Let ([

~begin = Reports » Selector::gDateBegin ;
~end = Reports » Selector::gDateEnd ;
~type = Reports » Selector::gPaymentType


];

ExecuteSQL (

"
SELECT SUM ( n.commission )

FROM Commission n

INNER JOIN Payments p
ON p._pk_payment_id = n._fk_payment

WHERE p.date >= ? AND p.date <= ? AND n.commissionType = ?
"

;"";""; ~begin ; ~end ; "Sales"
)

)

Just trying to pull the total Sales commissions for a date range.

Thanks

 

Never mind. I got it. Just had to do some quoting...

Let ([

~begin = Reports » Selector::gDateBegin ;
~end = Reports » Selector::gDateEnd ;
~type = Reports » Selector::gPaymentType


];

ExecuteSQL (

"
SELECT SUM ( n.commission )

FROM Commission n

INNER JOIN Payments p
ON p.\"_pk_payment_id\" = n.\"_fk_payment\"

WHERE p.\"date\" >= ? AND p.\"date\" <= ? AND n.commissionType = ?
"

;"";""; ~begin ; ~end ; "Sales"
)

)

Edited by Ron Cates
Link to comment
Share on other sites

:beer: 

Cheers! you found a common mistake: use of keyword/reserved word in the name of a table or field (column). Consider renaming your 'date' field to something like 'paymentDate'. You'll be glad later. 

Link to comment
Share on other sites

This topic is 3056 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.