Firstly, find out Tom’s age; then, find out how many years Tom is older than David; then find out how many days earlier Tom came on board than Harry did.
SELECT age FROM employee WHERE name='Tom'
To find out how many years Tom is older than David:
SELECT (SELECT age FROM employee WHERE name='Tom') - (SELECT age FROM employee WHERE name='David') FROM dual
To find out how many days earlier Tom came on board than Harry did:
SELECT (SELECT join_date FROM employee WHERE name='Harry') - (SELECT join_date FROM employee WHERE name='Tom') FROM dual
You can’t carry out a SQL computation in separate query calls, which means the computational result of one SQL statement cannot be used by another one. Therefore, if users want to use the result of a statement, they would need to rewrite that statement as a nested subquery in the parent statement.
|1||=demo.query(“select * from employee”)|
esProc supports using individual records as variable values, thus it enables users to make full use of the intermediate results.