Professional Documents
Culture Documents
You probably already know that you pay 7.65% of your income in “FICA” taxes: 6.2%
Social Security tax (up to some maximum amount) and 1.45% Medicare tax. What you
might not know is that your employer pays these same amounts as well, so if you are
self-employed (i.e., an independent contractor) rather than working for a company,
then you have to pay that other 7.65% too – for a total of 15.3%. This is called
“Self-employment tax”.
Suppose you are an independent database consultant and you are paid a high hourly
rate for your expertise. Let’s figure out your total Self-employment tax for a
collection of years. Consider the tables INCOME and RATES, constructed by the
following script:
Write a script file Assignment6.sql containing just an anonymous PL/SQL block that
will do the following:
First, read the Social Security tax rate SSRate, Medicare tax rate MedRate, and
maximum Social Security tax MaxSS from the RATES table, store them in variables,
and output their values. (You may assume that the RATES table contains exactly one
record.)
Next, for each row in the INCOME table, read the year, hours worked, and hourly
rate, and compute your earnings for that year (hours worked times hourly rate).
From your earnings, compute the Self-employment tax for that year, which will have
two components:
The Self-employment tax is the sum of the Social Security tax and the Medicare tax.
Output each year’s information on a single line, displaying the year, your earnings
for the year, the Social Security and Medicare tax amounts, and the Self-employment
tax. (If you want to format the output nicely to line up the decimal points and
display exactly two digits to the right of each decimal point, use the to_char
function with format strings of appropriate lengths – but doing that is optional.)
Add the word ‘MAXSS’ to the end of each line in which the Social Security tax is
the maximum amount MaxSS.
Finally, compute the total Self-employment tax paid over all years in the INCOME
table, and output that value at the end. For the sample data given, the output
should be something like this (including the optional formatting):
(Of course, this is just an example – your anonymous PL/SQL procedure should work
in general, not just for the given sample data.)
Remarks:
1. You may copy and paste the script I supplied into SQLDeveloper to set up the
tables so that you can test your code, but your submitted solution should include
only the code you have written to solve the problem – not any of my code. Be sure
that your submitted script file is in a plain text format that can be run and
tested in SQLDeveloper.