What should be included in the file (see sample below): Your code for this question,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
What should be included in the file (see sample below): • Your code for this question, and • The output of that question (just the text, no screenshot); right after its code. Such as below: REM Q1. SELECT employee_id, Last_name, First_name, manager_id FROM Employees Where upper (first_name) like "ALEXS'; OUTPUT EMPLOYEE ID LAST NAME 103 Hunold REM Q2. code for question #2 OUTPUT of Q2. FIRST NAME Alexander MANAGER ID To begin with this homework assignment #1, please build the Oracle sample tables. Consider that some students may have different backgrounds in SQL, some hints are provided at the end of this file. 102 Questions #1 to #8 require the SQL select statements, carefully pay attention which tables are based for each question table: All the five tables Employees, Departments, Locations, Dept, EMP may be involved. • Use table Employees for this Q1. List the employee_id, last name, first name, manager (immediate supervisor) ID for those employees that their first name starts with "Alex". Use table LOCATIONS for this 02. Use table LOCATIONS for this Q2. Sometimes, we do not know how the database stores the literals (either all upper. Initial Capital, or all lower cases). Use the function UPPER, we may make our query case insensitive. In this question, you are required to use this technique. Display the Location's location_id, street_address, postal code, city, country_id for those location(s) that city name spells as Seattle-but we do not know how the literal letters (upper case, lower, or...) stored in database. Use table LOCATIONS for this Q3. When we design tables, it is better to use small unit as a column, not same as in our daily language. For the example of ADDRESS, we usually will define the columns of street address, city, state, state, zip code, country individually. When we output it as a composite address, we will use the concatenation operator, to merge some of these columns according to required format. Another similar case is the people's names defined with columns of first, middle, last names. Display the location ID, and its full address as one string. The format is ** street, city, state province, postal_code, country_id". Just list those locations they located in 'US' (country_id= 'us'). • Use table EMP for this Q4. Display the employees' empno, name (ename), salary (sal) and department ID for those whose immediate supervisor's name (ename) is Blake. You may refer to page 13 of Notelb_Advanced_SQL.docx to check the output. • Use table Employees and Departments for this Q5 List the department ID, department name and the number (how many) of employees that work in that department. The output will be sorted in order of number of employees in ascending order. Exclude those departments that have no employee yet. Use table Locations and Departments for this Q6 List the department ID, department name. Address (as in question 3. you may re-use some of the code from Q3) for those departments that have a department head assigned (manager_id is not null). • Use table Employees for this Q7 List the employee ID, last name, first name and salary for those whose last name is not unique among the employees. Use table Employees and Departments for this Q8 List the employee ID. last name, first name, their department ID, their immediate supervisor's ID (the manager ID in employees table) and their department head's ID. (the manager II in departments table) for those employees who work in department (ID) 60. and their immediate supervisor is not their department head/manager. Questions 9 and 10 are for PL/SQL coding. • Write an anonymous PL/SQL block. In the PL/SQL block, declare a variable called name, its data type uses anchored data type, same data type as the ename in the Emp table; also declare a variable named income, data type anchored as that of sal in Emp table. In the executable section, the program will assign the value of name as "JACKSON', salary as $1,234. Then use the DBMS OUTPUT.PUT_LINE (" ¹) command to print out the values of that name and income. Please use the function TO CHAR (income, ¹$99,999') to make the output of salary as popular money format like $1,234. • Write an anonymous PL/SQL block with a nested (inner) block. In the out block, declare a variable called "1stname" using varchar2 (25) as its data 1. f 11-11... ------- Write an anonymous PL/SQL block with a nested (inner) block. In the out block, declare a variable called "Istname" using varchar2 (25) as its data type with initial value of 'Jackson". You need to label the outer block, give it a name. In the inner block, declare two variables, one with the same name as "Istname" with data type of varchar2 (25). and assign the initial value as 'Wabash': define the second variable as "lastname" with data type of varchar2 (25), initial value as 'George'. In the executable section of inner block. print out the values of the variable "Istname" declared in the outer block and the values of the variable "Ismame" and "lastname" declared in inner block. Some hints. Q1. Use "like" clause for pattern match, such as below car Where first name like 'Alex*' ; -- this is case sensitive, Where upper (first_name) like 'ALEX Q2. Use the function: upper (column_name) 'string of upper case letters'; Q3. Use concatenation operation to combine the columns: SELECT .... street_address ||'||city ||', '||-- Q4. A subquery might make it easier in logic, such as WHERE mgr = (select empno from omp where ... AS Address What should be included in the file (see sample below): • Your code for this question, and • The output of that question (just the text, no screenshot); right after its code. Such as below: REM Q1. SELECT employee_id, Last_name, First_name, manager_id FROM Employees Where upper (first_name) like "ALEXS'; OUTPUT EMPLOYEE ID LAST NAME 103 Hunold REM Q2. code for question #2 OUTPUT of Q2. FIRST NAME Alexander MANAGER ID To begin with this homework assignment #1, please build the Oracle sample tables. Consider that some students may have different backgrounds in SQL, some hints are provided at the end of this file. 102 Questions #1 to #8 require the SQL select statements, carefully pay attention which tables are based for each question table: All the five tables Employees, Departments, Locations, Dept, EMP may be involved. • Use table Employees for this Q1. List the employee_id, last name, first name, manager (immediate supervisor) ID for those employees that their first name starts with "Alex". Use table LOCATIONS for this 02. Use table LOCATIONS for this Q2. Sometimes, we do not know how the database stores the literals (either all upper. Initial Capital, or all lower cases). Use the function UPPER, we may make our query case insensitive. In this question, you are required to use this technique. Display the Location's location_id, street_address, postal code, city, country_id for those location(s) that city name spells as Seattle-but we do not know how the literal letters (upper case, lower, or...) stored in database. Use table LOCATIONS for this Q3. When we design tables, it is better to use small unit as a column, not same as in our daily language. For the example of ADDRESS, we usually will define the columns of street address, city, state, state, zip code, country individually. When we output it as a composite address, we will use the concatenation operator, to merge some of these columns according to required format. Another similar case is the people's names defined with columns of first, middle, last names. Display the location ID, and its full address as one string. The format is ** street, city, state province, postal_code, country_id". Just list those locations they located in 'US' (country_id= 'us'). • Use table EMP for this Q4. Display the employees' empno, name (ename), salary (sal) and department ID for those whose immediate supervisor's name (ename) is Blake. You may refer to page 13 of Notelb_Advanced_SQL.docx to check the output. • Use table Employees and Departments for this Q5 List the department ID, department name and the number (how many) of employees that work in that department. The output will be sorted in order of number of employees in ascending order. Exclude those departments that have no employee yet. Use table Locations and Departments for this Q6 List the department ID, department name. Address (as in question 3. you may re-use some of the code from Q3) for those departments that have a department head assigned (manager_id is not null). • Use table Employees for this Q7 List the employee ID, last name, first name and salary for those whose last name is not unique among the employees. Use table Employees and Departments for this Q8 List the employee ID. last name, first name, their department ID, their immediate supervisor's ID (the manager ID in employees table) and their department head's ID. (the manager II in departments table) for those employees who work in department (ID) 60. and their immediate supervisor is not their department head/manager. Questions 9 and 10 are for PL/SQL coding. • Write an anonymous PL/SQL block. In the PL/SQL block, declare a variable called name, its data type uses anchored data type, same data type as the ename in the Emp table; also declare a variable named income, data type anchored as that of sal in Emp table. In the executable section, the program will assign the value of name as "JACKSON', salary as $1,234. Then use the DBMS OUTPUT.PUT_LINE (" ¹) command to print out the values of that name and income. Please use the function TO CHAR (income, ¹$99,999') to make the output of salary as popular money format like $1,234. • Write an anonymous PL/SQL block with a nested (inner) block. In the out block, declare a variable called "1stname" using varchar2 (25) as its data 1. f 11-11... ------- Write an anonymous PL/SQL block with a nested (inner) block. In the out block, declare a variable called "Istname" using varchar2 (25) as its data type with initial value of 'Jackson". You need to label the outer block, give it a name. In the inner block, declare two variables, one with the same name as "Istname" with data type of varchar2 (25). and assign the initial value as 'Wabash': define the second variable as "lastname" with data type of varchar2 (25), initial value as 'George'. In the executable section of inner block. print out the values of the variable "Istname" declared in the outer block and the values of the variable "Ismame" and "lastname" declared in inner block. Some hints. Q1. Use "like" clause for pattern match, such as below car Where first name like 'Alex*' ; -- this is case sensitive, Where upper (first_name) like 'ALEX Q2. Use the function: upper (column_name) 'string of upper case letters'; Q3. Use concatenation operation to combine the columns: SELECT .... street_address ||'||city ||', '||-- Q4. A subquery might make it easier in logic, such as WHERE mgr = (select empno from omp where ... AS Address
Expert Answer:
Answer rating: 100% (QA)
The question seems to relate to writing SQL queries for a given database schema that includes tables such as Employees Departments Locations etc Unfor... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these databases questions
-
1. Calculate how long it would take your current personal or family savings to double at the current interest rate you are being offered by your bank. What will it take for you or your family to...
-
THIRD AVENUE SOFTWARE HEALTH-CARE APP PROJECT This case is new for the ninth edition of Information Technology Project Management . The case provides an opportunity to apply agile and Scrum...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Find all conjugates in C of the given number over the given field. 1+2 over Q
-
Light is incident normally on the short face of a 30o ?? 60? ?? 90" prism (Fig. 33.50). A drop of liquid is placed on the hypotenuse of the prism. If the index of the prism is 1.62, find the maximum...
-
Figure P8.13 shows the block diagram of a closed loop control of a linearized magnetic levitation system (Galvo, 2003).. Assuming A = 1300 and = 860, draw the root locus and find the range of K for...
-
Determine the probability mass function of \(X\) from the following cumulative distribution function: \[ F(x)=\left\{\begin{array}{lr} 0 & x. \] Figure 3.3 displays a plot of \(F(x)\). From the plot,...
-
The Village of Hawksbill issued $4,000,000 in 5 percent general obligation, tax-supported bonds on July 1, 2016, at 101. A fiscal agent is not used. Resources for principal and interest payments are...
-
You are evaluating a project with the following cash flows: initial investment is $ - 1 1 , and the expected cash flows for years 1 - 3 are $ 6 , $ 1 4 and $ 1 1 ( all cash flows are in millions of...
-
Jamie Lee Jackson, age 26, is in her last semester of college and is anxiously waiting for graduation day that is just around the corner! She still works part-time as a bakery clerk, has been...
-
Margaret is 20 years old and has just discovered that she has a G-spot. She is very happy about this discovery but wonders why she was never taught about this before and why more women do not have...
-
For a company, cash is one of the most liquid assets. As a result, it is also the asset most susceptible to theft. Identify at least two management control issues related to cash. What role does the...
-
Calculate accounting breakeven and cash breakeven points by ignoring the tax effects for the following number. No. Unit price (RM) Unit variable cost (RM) Fixed costs (RM) Depreciation (RM) 1 5,640...
-
Transactions for May 1-May Pay payroll expense for the month of $12,000 3-May Pay Rent for month of $3,000 5-May Perform painting work for a customer and receive $10,000 cash 7-May Buy Computer...
-
How do you find the over/underapplied overhead with these numbers? Estimated Overhead Cost $240,000 Estimated Direct Labor Hours 29,000 Actual Direct Labor Hours 31,587 Estimated Machine Hours 74,000...
-
1) Complete the following activity. In 2014, "Prince" Frank, Joe and Nord, Inc, formed "the Candy Co, LLC". At formation, the entity did not file Form 8832. For 2041 and therefore, the Candy Co LLC...
-
Please solve this problem numerically using EXCEL except where indicated. Consider an ore mine that is estimated to contain about 102,000 tons of ore suitable for extraction. Estimated market demand...
-
In 1995 Miguel purchased a home for $130,000. In 2000 he sold it for $170,000 and immediately purchased another one for $180,000, which he sold in 2007 for $235,000. How much taxable capital gain, if...
-
If Charles, a 16-year-old child model, earns $50,000 a year and is completely self supporting even though he lives with his parents, can his parents claim him as a dependent? Why or why not?...
-
During 2012, Palo Fiero purchases the following property for use in his manufacturing business: Palo uses the accelerated depreciation method under MACRS, if available, and does not make the election...
-
Skyler is covered by his company's health insurance plan. The health insurance costs his company $3,500 a year. During the year, Skyler is diagnosed with a serious illness and the health insurance...
-
(a) Among 880 smart phones sold by a retailer, 72 required repairs under the warranty. Estimate the probability that a new phone, which has just been sold, will require repairs under the warranty....
-
A car rental agency has 19 compact cars and 12 intermediate-size cars. If four of the cars are randomly selected for a safety check, what is the probability of getting two of each kind?
-
With reference to Exercise 3.34, suppose that the questionnaire filled in by one of the 150 persons is to be double-checked. If it is chosen in such a way that each questionnaire has a probability of...
Study smarter with the SolutionInn App