using sub selects
Posted: Mon Mar 15, 2010 8:23 pm
Hello,
Faced with the need to add the total of one column from a small set of child records to a number in a single parent record, where that parent record is one row of output in a report what is my best approach?
Should I create a separate report that defines a key figure and then define relations that allow this report to be executed for each row retrieved by the "parent" report, where that parent report defines a formula field that adds the key figure to another field in the report?
Or is it possible, and better, to use SQL script in the underlying view or view dictionary. In the past I have gotten error messages from DAI warning that the use of select statements or sub-selects are not allowed in the context of whatever my report was trying to do. (I never understood what my error was so just worked around it.)
When I look at the SQL DAI generates for its reports I see lots of nested select statements -- so I am thinking I should be able to add SQL to my underlying view or define a global SQL var in its dictionary that would do something like:
Select sum(AA_Price) from Jcoraa where Jcoraa.job_no = Jcjobs.Idno and Jcoraa.Ok_to_Bill = 1
Any guidance would be appreciated.
Thanks,
Bob
Faced with the need to add the total of one column from a small set of child records to a number in a single parent record, where that parent record is one row of output in a report what is my best approach?
Should I create a separate report that defines a key figure and then define relations that allow this report to be executed for each row retrieved by the "parent" report, where that parent report defines a formula field that adds the key figure to another field in the report?
Or is it possible, and better, to use SQL script in the underlying view or view dictionary. In the past I have gotten error messages from DAI warning that the use of select statements or sub-selects are not allowed in the context of whatever my report was trying to do. (I never understood what my error was so just worked around it.)
When I look at the SQL DAI generates for its reports I see lots of nested select statements -- so I am thinking I should be able to add SQL to my underlying view or define a global SQL var in its dictionary that would do something like:
Select sum(AA_Price) from Jcoraa where Jcoraa.job_no = Jcjobs.Idno and Jcoraa.Ok_to_Bill = 1
Any guidance would be appreciated.
Thanks,
Bob