February 09, 2006, 05:55 AM
Anubha SainiSubqueries in focus
can we write subqueries in focus. I don't want to execute sql but the report requires a subquery. How can we do it in webfocus
let say for e.g
i have query
select * from emp where sal=(select max(sal) from emp);
How can we get result of this query in webfocus. can anyone help me
February 09, 2006, 08:26 AM
mgrackinThe FOCUS language does not have subqueries like SQL. However, the following is a example of duplicating the same functionality with a HOLD file.
The first pass of the data creates a file containing the MAX value. the second pass then uses the file in a selection statement to select only records that have the MAX value.
TABLE FILE CAR
SUM MAX.RCOST
ON TABLE SAVE AS MAXVAL
END
-RUN
TABLE FILE CAR
PRINT RCOST DCOST
BY COUNTRY
BY CAR
BY MODEL
BY BODYTYPE
WHERE RCOST IN FILE MAXVAL
END
February 09, 2006, 08:29 AM
mgrackinHere's another example of how to get the same result using a multiverb request.
TABLE FILE CAR
SUM MAX.RCOST
PRINT RCOST DCOST
BY COUNTRY
BY CAR
BY MODEL
BY BODYTYPE
WHERE TOTAL RCOST EQ MAX.RCOST
END