Usually (but not always) you can combine two SQL statements in one - avoiding the complexity of sub-reports.
For an (simpler) example:
SELECT CustomerNum -- Returns number 919 FROM RecentOrder WHERE OrderNum = 23455; SELECT FirstName, LastName, EmailAddress FROM Customer WHERE CustomerNum = 919
They can be combined in several ways:
SELECT FirstName, LastName, EmailAddress FROM Customer WHERE CustomerNum = (SELECT CustomerNum FROM RecentOrder WHERE OrderNum = 23455 ) SELECT FirstName, LastName, EmailAddress FROM Customer AS C JOIN RecentOrder AS O ON C.CustomerNum = O.CustomerNum WHERE O.OrderNum = 23455
Depending on your DBMS, you can also use the WITH clause up:
WITH name1 AS ...query1...: SELECT ... FROM ...list including name1... WHERE ...
It’s worth the effort to combine queries that make you think you need a sub-report. If you still need an extra report, you need more specialist help than I can offer.
source share