We have two views
View A – EMP (employee data)
- EMP_ID (Primary Key)
View B – SALARY (salary data of employees per month)
- SAL_ID (Primary Key)
- EMP_ID (reference to EMP.EMP_ID)
We want to query the salary per department and month. The report must contain only the DEPARTMENT_NAME, MONTH and SUM(SALARY). In order to achieve this, we made a query of View A and a sub-query of View B only with the required columns.
Unfortunately this gives us no chance to join the two queries to get the desired result.
We only can join columns that are used in the query. But this would not allow us to group the data as it is required in this report.