• 0

# Calculated Field Help

## Question

I have a calculated field in my datapage to find the biggest "Clean_Serial_Number" under a particular Job_ID. There are many serial numbers under each job so I want it to find the max serial number under JUST that job. Right now, this field is just displaying the max "Clean_Serial_Number" from all the data, not just from the Job_ID.

```SELECT MAX(Clean_Serial_Number) FROM tbl_ggl_job_lines
WHERE Job_ID = [@field:Job_ID]```

What am I doing wrong?

## Recommended Posts

• 0
14 minutes ago, pmcfarlain said:

I have a calculated field in my datapage to find the biggest "Clean_Serial_Number" under a particular Job_ID. There are many serial numbers under each job so I want it to find the max serial number under JUST that job. Right now, this field is just displaying the max "Clean_Serial_Number" from all the data, not just from the Job_ID.

```SELECT MAX(Clean_Serial_Number) FROM tbl_ggl_job_lines
WHERE Job_ID = [@field:Job_ID]```

What am I doing wrong?

What DataPage is this? try using

`WHERE Job_ID = target.[@field:Job_ID]`

##### Share on other sites

• 1
47 minutes ago, pmcfarlain said:

Same result from this:

```SELECT MAX(Clean_Serial_Number) FROM tbl_ggl_job_lines
WHERE Job_ID = tbl_ggl_job_lines.[@field:Job_ID]```

This is a submission form datapage. The job ID passes as a parameter from a previous page. Job ID is displayed as a non-editable field. This calculated value is just meant to show the person submitting the form what the max serial number is so they can use the next one (if the max is 1, the user should input 2 into the Serial Number submission field).

ah no, have you tried target? just 'target', like the one I've sent, not the table name.

##### Share on other sites

• 0

Same result from this:

```SELECT MAX(Clean_Serial_Number) FROM tbl_ggl_job_lines
WHERE Job_ID = tbl_ggl_job_lines.[@field:Job_ID]```

This is a submission form datapage. The job ID passes as a parameter from a previous page. Job ID is displayed as a non-editable field. This calculated value is just meant to show the person submitting the form what the max serial number is so they can use the next one (if the max is 1, the user should input 2 into the Serial Number submission field).

##### Share on other sites

• 0
11 minutes ago, TellMeWhy said:

ah no, have you tried target? just 'target', like the one I've sent, not the table name.

Whoops my bad! That worked thanks a bunch!

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.