BasSchouten
IS-IT--Management
I'v got two tables SAL and DVB
DVB contains info on a workingcontract
SAL contains information historic salaries on those workingcontracts. The tables consists of the following columns:
I want to create a view of salaries of a certain contract and include the enddate of that salary. The enddate of salary X should be calculated as follows:
If there exists a salary Y of the same contract that starts after salary X, then the enddate of salary X is the startdate of Salary Y - 1 day.
If salary X is the latest salary, then the enddate of the salary is the enddate of the contract.
I'v created the separate coding for the two options:
Option 1:
Option 2:
How do i incorporate these two options as one field in a view definition? Bas Schouten
System Development & Webdesign
CBIS BV Holland
DVB contains info on a workingcontract
SAL contains information historic salaries on those workingcontracts. The tables consists of the following columns:
Code:
DVB:
DVBDVBIDN (identity)
DVBDVBDTB (startdate of contract)
DVBDVBDTE (enddate of contract, 9999-12-31 if no enddate)
SAL:
SALSALIDN (identity)
SALDVBIDN (foreign key into DVB)
SALSALSAL (salary)
SALSALDTB (Startdate of this salary)
I want to create a view of salaries of a certain contract and include the enddate of that salary. The enddate of salary X should be calculated as follows:
If there exists a salary Y of the same contract that starts after salary X, then the enddate of salary X is the startdate of Salary Y - 1 day.
If salary X is the latest salary, then the enddate of the salary is the enddate of the contract.
I'v created the separate coding for the two options:
Option 1:
Code:
SELECT MIN(SALSALDTB)-1 FROM PDPSAL01 SAL2
WHERE SAL1.SALDVBIDN = SAL2.SALDVBIDN
AND SAL2.SALDVBDTB > SAL1.SALSALDTB
Option 2:
Code:
SELECT DVBDVBDTE FROM PDPDVB01
WHERE SAL1.SALDVBIDN = DVBDVBIDN
How do i incorporate these two options as one field in a view definition? Bas Schouten
System Development & Webdesign
CBIS BV Holland
