Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Hi all

I'm attempting to modify an existing (working) Execute SQL calculation to further include another step. The calculation field is inside my Projects table (Unstored, From Projects). The SQL code references data inside the Assets table to give me a count of the applicable records.

This is my current code:

ExecuteSQL (
"SELECT Count (*)
FROM Assets
WHERE EntryModeCheck = 1"
; "" ; "" )

I need the SQL query to reference an additional field where I need the EntryModeCheck to still execute, however Projects::ProjectID must equal Assets::ProjectID to only count the records inside the Project parent record. I figure an INNER JOIN is needed, but all I can get is a ?

This is where I've stopped trying:

ExecuteSQL (
"SELECT Count (*)
FROM Assets
INNER JOIN Projects ON Assets.ProjectID = Projects.ProjectID;
WHERE EntryModeCheck = 1"
; "" ; "" )

Can anyone spot what I'm doing wrong here?

If I follow this correctly, you want to do:

ExecuteSQL (
"SELECT Count (*)
FROM Assets
WHERE EntryModeCheck = 1 AND ProjectID = ?"
; "" ; "" ; ProjectID )

When this is evaluated from the context of the Projects table, the question mark will be replaced by the value of the ProjectID field in the current record.

--
P.S. I would not use ExecuteSQL() in a calculation field; in some circumstances it can be really slow. If EntryModeCheck is a Boolean field, you can use a summary field or an aggregate function to count/sum it directly, without going through SQL.

 

  • Author
37 minutes ago, comment said:

If I follow this correctly, you want to do:


ExecuteSQL (
"SELECT Count (*)
FROM Assets
WHERE EntryModeCheck = 1 AND ProjectID = ?"
; "" ; "" ; ProjectID )

When this is evaluated from the context of the Projects table, the question mark will be replaced by the value of the ProjectID field in the current record.

--
P.S. I would not use ExecuteSQL() in a calculation field; in some circumstances it can be really slow. If EntryModeCheck is a Boolean field, you can use a summary field or an aggregate function to count/sum it directly, without going through SQL.

 

comment

SQL mod did the trick. As did using a summary field instead. Thank you.

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.