SHARE
TWEET

Untitled

a guest Jun 16th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Week                                    Contract    
  2. emp_id | starting   | data1 |  ...   emp_id | from_date  | data2 | ...
  3. -------|------------|-------|--      -------|------------|-------|--
  4. 12     | 2019-01-08 | abcd  |        12     | 2018-08-01 | efgh  |
  5. 12     | 2019-01-15 | abcd  |        13     | 2018-10-02 | efgh  |
  6. 12     | 2019-01-22 | abcd  |        13     | 2018-01-15 | ijkl  |
  7. 13     | 2019-01-08 | abcd  |        13     | 2018-03-19 | mnop  |
  8. 13     | 2019-01-15 | abcd  |        14     | 2017-02-02 | efgh  |
  9. 13     | 2019-01-22 | abcd  |        15     | 2018-01-19 | efgh  |
  10.      
  11. SELECT * FROM contract
  12. WHERE contract.emp_id = @emp_id AND contract.from_date <= @starting
  13. ORDER BY contract.from_date DESC
  14. LIMIT 1
  15.      
  16. emp_id | starting   | from_date  | data1 | data2 | ...
  17. -------|------------|------------|-------|-------|--
  18. 12     | 2019-01-08 | 2018-08-01 | abcd  | efgh  |
  19. 12     | 2019-01-15 | 2018-08-01 | abcd  | efgh  |
  20. 12     | 2019-01-22 | 2018-08-01 | abcd  | efgh  |
  21. 13     | 2019-01-08 | 2018-10-02 | abcd  | efgh  |
  22. 13     | 2019-01-15 | 2019-01-15 | abcd  | ijkl  |
  23. 13     | 2019-01-22 | 2019-01-15 | abcd  | ijkl  |
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top