Jump to content
Server Maintenance This Week. ×

Sum hours worked from related table with matching value


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

Recommended Posts

Hi all. Attempting to sum hours worked using SQL where a separate field matches a particular value in another field.

The calculation is determined from the "Tax Year" table.

The calculation references a child table where the job entries are created - Relationship is: Tax Year::YEAR = Job Lines::YEARid

ExecuteSQL (
"SELECT Sum (HRS TOTAL)
FROM \"Job Lines\"
WHERE IA = 'Y' 
YEARid = ? " ; "" ; "" ;
"" ; "" ; TAX YEAR::PrimaryKey 
)

I keep getting a ? as a result. My suspicions are somewhere in the last three lines of the calculation. Any ideas?

Edited by madman411
Link to comment
Share on other sites

  1. You need to quote both field names that contain a space;
  2. You need to add AND between the two conditions of WHERE;
  3. You need to remove the 2 redundant empty strings after the query:
ExecuteSQL (
"SELECT Sum (\"HRS TOTAL\")
FROM \"Job Lines\"
WHERE IA = 'Y' AND
YEARid = ?" ; 
"" ;  "" ; TAX YEAR::PrimaryKey 
)

 

Edited by comment
  • Like 1
Link to comment
Share on other sites

This topic is 449 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.