Last active
December 22, 2015 08:39
-
-
Save yucao24hours/6446350 to your computer and use it in GitHub Desktop.
「勤続年数に応じてボーナスを支給したい。ついては、支払日を2007年度として、入社年度との差で1年毎に1000円上乗せしてくれ」(SQL書き方ドリル 第4章その6 より)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE | |
Salary | |
SET | |
Amount | |
= Amount + | |
( | |
SELECT | |
(2007 - e.HireFiscalYear) * 1000 | |
FROM | |
Employees AS e | |
WHERE | |
Salary.EmployeeID = e.EmployeeID | |
) | |
WHERE | |
PayDate = '2008-02-14' | |
AND | |
EXISTS | |
( | |
SELECT | |
'X' | |
FROM | |
Employees AS e | |
WHERE | |
Salary.EmployeeID = e.EmployeeID | |
) | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment