CREATE VIEW T1 AS SELECT * FROM FOOTABLE WHERE X > Y;
CREATE VIEW T2
AS SELECT EMPNO,CHARGE AS AMT,WHEN AS TIME
FROM T1 A, BARTABLE B
WHERE A.SERIAL = B.SSN;
SELECT EMPNO,SUM(AMT) FROM T2 GROUP BY EMPNO;
This would be the same thing as the procedure you explained (based on my understanding of it's meaning at least)