I am trying to use a SQL query in a calculated field to calculate the max value in a sub-group of data. When I hard code the formula as below, it works fine.
SELECT Max(CY_Inc) FROM Pohl_Data_Temp
WHERE cert = '8426' OR cert='7506' OR cert='660' OR cert='11681' OR cert='29679' OR cert='9507'
What I am trying to do is fill in my where statement dynamically from a field in my database. When I use the following formula, it returns a blank result.
SELECT Max(CY_Inc) FROM Pohl_Data_Temp
WHERE cert = [@field:search_alpha]
Field [search_alpha] = '8426' OR cert='7506' OR cert='660' OR cert='11681' OR cert='29679' OR cert='9507'
Field [cert] is a unique ID field
Since the hard coded formula works, I believe that I have the syntax correct, leading me to conclude that a SQL Select in a calculated field cannot use a field to provide the conditions for the where statement.
I have not used a lot of SQL in calculated fields, so it is possible that I am missing something here.
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.
Question
eetimm
I am trying to use a SQL query in a calculated field to calculate the max value in a sub-group of data. When I hard code the formula as below, it works fine.
SELECT Max(CY_Inc) FROM Pohl_Data_Temp
WHERE cert = '8426' OR cert='7506' OR cert='660' OR cert='11681' OR cert='29679' OR cert='9507'
What I am trying to do is fill in my where statement dynamically from a field in my database. When I use the following formula, it returns a blank result.
SELECT Max(CY_Inc) FROM Pohl_Data_Temp
WHERE cert = [@field:search_alpha]
Field [search_alpha] = '8426' OR cert='7506' OR cert='660' OR cert='11681' OR cert='29679' OR cert='9507'
Field [cert] is a unique ID field
Since the hard coded formula works, I believe that I have the syntax correct, leading me to conclude that a SQL Select in a calculated field cannot use a field to provide the conditions for the where statement.
I have not used a lot of SQL in calculated fields, so it is possible that I am missing something here.
I appreciate any thoughts and insights!
Link to comment
Share on other sites
11 answers to this question
Recommended Posts
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.