Create and populate the birthday-distribution table

Assignment Help PL-SQL Programming
Reference no: EM131158907

2) CSC 352 and CSC 452-

The BIRTHDAY_DISTRIBUTION table consists of every day of the year, from January 1 to December 31, along with a ranking based on how many babies were born in the United States on that date between 1973 and 1999. Rank 1 is the most popular, rank 2 is the next most popular, and so forth.

Create and populate the BIRTHDAY_DISTRIBUTION table by using the following SQL statements.

CREATE TABLE birthday_distribution
(MONTH NUMBER,
DAY NUMBER,
RANK NUMBER);

INSERT INTO birthday_distribution SELECT * FROM hchen.birthday_distribution;
COMMIT;

SELECT COUNT(*) FROM birthday_distribution;

Please make sure that there are 366 rows in your BIRTHDAY_DISTRIBUTION table.

In the BIRTHDAY_DISTRIBUTION table, you can find that September 16 is the most popular birthday (rank = 1) and February 29 is the least popular birthday (rank = 366). Excluding leap years, December 25 is the least popular birthday (rank = 365).

Begin(2a) CSC 352 only

2a) CSC 352 only

Write a PL/SQL anonymous block that accepts an integer n (1 ≤ n ≤ 5) from the user input and displays n most popular birthdays along with the ranks for each month. Sort your output in ascending order by months, and then most popular birthdays.

• You will lose 10 points if the title lines are missing in your output.
• You will lose 10 points if your output has an incorrect format. For example, you must display the birthdays and ranks for the same month in one line.
• You may hard-corded values of months (e.g., FOR idx IN 1..12 LOOP).
• If you have hard coded the birthdays or ranks (e.g., DBMS_OUPT.PUT_LINE('1 (20/ 240)(14/260)')) in your PL/SQL block, you will receive 0 points.
• To avoid complicating issues, you can assume that the user always enters input from keyboard that consists only of the digits 0 through 9 and Enter.
• Submitting more than one PL/SQL program will receive 0 points.

Test your program. You must ensure that the output of your program matches the following output (one month per line):

End(2a) CSC 352 only

Begin (2b) CSC 452 only

2b) CSC 452 only

Write a PL/SQL anonymous block that accepts an integer n (1 ≤ n ≤ 6) from the user input and displays n most and n least popular birthdays along with the ranks for each month. Sort your output in ascending order by months, most popular birthdays, and then least popular birthdays.

• You will lose 10 points if the title lines are missing in your output.

• You will lose 10 points if your output has an incorrect format.For example, you must display the birthdays and ranks for the same month in one line.

• You may hard-corded values of months (e.g., FOR idx IN 1..12 LOOP).

• If you have hard coded the birthdays or ranks (e.g., DBMS_OUPT.PUT_LINE('1 (20/ 240)(14/260)')) in your PL/SQL block, you will receive 0 points.

• To avoid complicating issues, you can assume that the user always enters input from keyboard that consists only of the digits 0 through 9 and Enter.

• Submitting more than one PL/SQL program will receive 0 points.

Test your program. You must ensure that the output of your program matches the following output (one month per line):

Case 1)

Case 2)

Case 3)

Case 4)

......

End(2b) CSC 452 only

3) CSC 352 and CSC 452-

Begin(3a) CSC 352 only

3a) CSC 352 only

Based on the tables created in Assignment #1, write a PL/SQL program that accepts an employee ID from the user input and displays1) employee name, job, hire date, and his/her department name (If the given employee does not belong to any department, the department name is shown as "------" in your output.), and 2) all employees (alone with their jobs and hire dates) who work in the same department as the given employee andwere hired beforethe given employee (or "NO OUTPUT"). Sort your output by the employee name.

• Hard coding(e.g., IF v_emp_id = 7596 THEN v_1 := ...) will receive 0 points.
• You will lose 10 points if the title lines are missing in your output.
• You will lose 10 points if your output has an incorrect format.
• Submitting more than one PL/SQL program will receive 0 points.

To avoid complicating issues, you can assume that the user always enters input from keyboard that consists only of the digits 0 through 9 and Enter.

Test your program. You must ensure that the output of your program matches the following sample output:

Case 1)

Output:

Case 2)

Output:

Case 3)

Output:

Case 4)

Output:

End(3a) CSC 352 only

Begin(3b) CSC 452 only

3b) (CSC 452 only)

Based on the tables created in Assignment #1, write a PL/SQL anonymous block that displays all employees who were hired on the days of the week on which the highest number of employees were hired. The output of the program must contain all the hire dates, employee names, job, their corresponding department names (If an employee does not belong to any department, the department name is shown as "------" in your output.), and the names and salaries of their corresponding managers (If an employee does not have a manager, the manager name and salary are shown as "------" in your output.). Sort your output by days of the week (Monday, Tuesday, ..., Friday) and the hire date.

• You will lose 10 points if the title lines are missing in your output.
• You will lose 10 points if your output has an incorrect format.
• Hard coding (e.g., IF v_day = 'Thursday' OR v_day = 'Friday' OR v_max_num = 4 THEN ...) will receive 0 points.
• Submitting more than one PL/SQL program will receive 0 points.

Hints:

(1) TO_CHAR(hire_date, 'Day')
(2) TRIM(TO_CHAR(hire_date, 'Day'))
(3) TRIM(TO_CHAR(hire_date, 'D')
(4) GROUP BY TO_CHAR(hire_date, 'Day')

The output of your program must match the following:

End(3b) CSC 452 only

Attachment:- SQL_Assignment.rar

Reference no: EM131158907

Questions Cloud

Purchasing cloth from british manufacturers : Who protested by meeting to spin yarn for cloth and avoid purchasing cloth from British manufacturers?
What role should external factors of demand play : What role should external factors of demand play in successful business models?- What is "Business Model Design and Innovation"?
House of burgesses to condemn the stamp act : In History, Who urged the House of Burgesses to condemn the Stamp Act?
Calculate the mass of the sample of silver : Calculate the energy required to raise the temperature of 1.0 mol Ag by 1.0C (called the molar heat capacity of silver).
Create and populate the birthday-distribution table : The BIRTHDAY_DISTRIBUTION table consists of every day of the year, from January 1 to December 31. Create and populate the BIRTHDAY_DISTRIBUTION table by using the following SQL statements.
Describe and explain scenes that apply to the social theme : Explain your interpretation of the meanings of the identified nonverbal communications and symbolism. Summarize how these interpretations are important to the sociological understanding of your chosen social inequality or social class theme.
Philosopher stated that all individuals possessed : "What philosopher stated that all individuals possessed certain ""natural rights""-such as life, liberty, and the pursuit of property?"
Calculate the specific heat capacity and molar heat capacity : Calculate the specific heat capacity and the molar heat capacity of mercury.
Execution of the queen : Why did burke lament the execution of the Queen? What did her death mean for the future of europe?

Reviews

Write a Review

PL-SQL Programming Questions & Answers

  Create a database model

Create a database model and Submit the table creation statements for the Database Model.

  Write pl-sql procedures and functions

Write PL/SQL procedures and functions to populate and query that database

  Sql questions

Write a query to display using the employees table the EMPLOYEE_ID, FIRST_NAME, LAST_NAME and HIRE_DATE of every employee who was hired after to 1 January, 1995.

  Run the lab_03_01.sql script

Run the lab_03_01.sql script in the attached file to create the SAL_HISTORY table. Display the structure of the SAL_HISTORY table.

  Write sql queries

Write a query to display the last name, department number, and salary of any employee whose department number and salary both match the department number and salary of any employee who earns a commission.

  Explaining sql insert statement to insert new row in cds

Write down a SQL insert statement to insert new row in "CDS" table.

  Write down name of actors in ascending order

Write down actors (or actress, your choice, but not both) who have won at least two (2) Academy Awards for best actor/actress. Provide the actor name, movie title & year. Order the result by actor name."

  What is an sql injection attack

What is an SQL injection attack? Explain how it works, and what precautions must be taken to prevent SQL injection attacks.What are two advantages of encrypting data stored in the database?

  Determine resonant frequency in series rlc resonant circuit

Given the series RLC resonant circuit in the figure, operating at variable frequency, determine: The resonant frequency ω o ,  The circuit’s quality factor Q , The cut-off frequencies, f 1  & f 2  and the bandwidth BW

  Query that uses cube operator to return lineitemsum

Write summary query which uses CUBE operator to return LineItemSum (which is the sum of InvoiceLineItemAmount) group by Account(an alias for AccountDesciption).

  Query to show customers were missing for existing orders

As DBA, your manager called a meeting and asked why there are so many orders for customers that don't exist in the customer table. Write query which would shows which customers were missing for existing orders. Use a join or a subquery.

  Sql query into a relational algebra statement

Turn this SQL query into a relational algebra statement? SELECT Request.reqfor, Ordering.invamt, Ordering.invnbr, Ordering.invdat

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd