Question

In: Computer Science

(SQL Coding) Create a READ ONLY view called: VIEW_EMP_SAL_INFO Calculate the following: The minimum, average, maximum,...

(SQL Coding)

Create a READ ONLY view called: VIEW_EMP_SAL_INFO

Calculate the following: The minimum, average, maximum, and sum of all salaries, and a count to show the records used. Have the calculations grouped by department name. (You will need to join with the departments table.) Round the functions to two decimal points. Give the read only constraint the name of vw_emp_sal_info_readonly.

Solutions

Expert Solution

// Rate my Solution:

//Comments if any doubt:

CODE:

-- (with check option) or (with read only) is used to create a read-only view.
-- joining employee and department table with dno in employee and dnum in department.
-- grouping table values according to the dname and finding min max sum avg count using aggerate functions.

create or replace view view_emp_sal_info as
   select
       dname ,
       round(min(salary),2) minimum_salary ,
       round(max(salary),2) maximum_salary ,
      round(avg(salary),2) Average_salary,
      round(sum(salary),2) Sum_of_salaries ,
      count(*) Number_of_employee
   from employee join department on dno=dnum
    group by dname
    with check option;

//THERE IS ANOTHER METHOD

create or replace view view_emp_sal_info as
   select
       dname ,
       round(min(salary),2) minimum_salary ,
       round(max(salary),2) maximum_salary ,
      round(avg(salary),2) Average_salary,
      round(sum(salary),2) Sum_of_salaries ,
      count(*) Number_of_employee
   from employee join department on dno=dnum
    group by dname
    with read only;

Code(Screenshots):

Output:

MY EMPLOYEE AND DEPARTMENT TABLE:


Related Solutions

(SQL Coding) Create a read only view called view_emp_salary_rank_ro that selects the last name and salary...
(SQL Coding) Create a read only view called view_emp_salary_rank_ro that selects the last name and salary from the o_employees table and ranks the salaries from highest to lowest for the top three employees.
(SQL Coding) Create a view based on the Job History table. Name the view: view_job_history. Select...
(SQL Coding) Create a view based on the Job History table. Name the view: view_job_history. Select all columns to be included in the view. Add a WHERE clause to restrict the employee_id to be greater than 150. Add the WITH READ ONLY option. Show me the code used to create the view and the results of a select statement on the view.
Choose only ONE of the following to write your post (minimum of 200 words, maximum of...
Choose only ONE of the following to write your post (minimum of 200 words, maximum of 500 words): 1. You learned that there are 4 components of the AD: consumption spending, investment spending, government spending, and spending on exports minus imports. A change in one of these components would lead to a shift in the AD curve, causing an impact on real GDP and price level. Give one original example for each component explaining how this example would shift the...
Choose only ONE of the following to write your post (minimum of 200 words, maximum of...
Choose only ONE of the following to write your post (minimum of 200 words, maximum of 500 words) Most economies around the world make efforts to always keep their inflation levels low. Although too much inflation is considered bad for an economy, the opposite of inflation, deflation, is considered even worse. You learned that deflation happens when most prices in the economy are falling. Do a brief research on the internet and explain why deflation is so bad for any...
For the minimum and maximum allowed pH values of blood, calculate the following ratios (you may...
For the minimum and maximum allowed pH values of blood, calculate the following ratios (you may use relevant Ka values that are tabulated for 25C in Appendix D of your textbook): [Species #1] / [Phosphoric Acid] [Species #2] / [Phosphoric Acid] [Species #3] / [Phosphoric Acid] Appendix D says: Phosphoric Acid H3PO4 Ka1 7.5 x 10 ^ -3 Ka2 6.2 x 10 ^-8 Ka3 4.2 x 10 ^-13
SUBJECT: PROGRAMMING IN SQL 1. Create a view named vDepartmentInstructors that returns these columns: the DepartmentName...
SUBJECT: PROGRAMMING IN SQL 1. Create a view named vDepartmentInstructors that returns these columns: the DepartmentName column from the Departments table the LastName, FirstName, Status, and AnnualSalary columns from the Instructors table. 2. Write a SELECT statement that returns all the columns from the vDepartmentInstructors view that you created in question 1. Return one row for each fulltime instructor in the English department. 3. Write an UPDATE statement that updates the vDepartmentInstructors view you created in question 1 so it...
Create a new SQL Developer SQL worksheet and create/run the following TWO (2) queries and save...
Create a new SQL Developer SQL worksheet and create/run the following TWO (2) queries and save your file as Comp2138LabTest1_JohnSmith100123456.sql (replace JohnSmith 100123456 with your name and student ID). Please place comment that includes your name and your student ID at the top of your script and number your queries using comments sections. Each query carries equal weight. A selection of the expected result set has been shown below for your convenience. Your output should match with this sample output....
Using SQL create a new database called school_app. Create a student table with fields id (auto...
Using SQL create a new database called school_app. Create a student table with fields id (auto increment), first_name, last_name. Create a course table with fields id (auto increment), course code (such as ITC or MTH), and course number (such as 100 or 295). Note that the relationship between student and course is many-to-many (n:m). Create a join table called student_course that implements the n:m relationship with fields id (auto increment), student_id, course_id, and grade (which has values 0, 1, 2,...
The function needs to have at least one maximum or minimum value.    A.       Create a...
The function needs to have at least one maximum or minimum value.    A.       Create a function that requires quotient rule (with a variable in the denominator). The function needs to have at least one maximum or minimum value.    Please show work and guidance! "Provide graph" 1. Find any horizontal and vertical asymptotes for this graph as well. 2.        Find the domain of f(x) 3.       Find the y-intercept f(x) 4.        End behavior: Find the limit of the f(x) as...
In C, create a program that displays the minimum and maximum values stored in a data...
In C, create a program that displays the minimum and maximum values stored in a data file "datafile.txt". Use the following function prototype:  void minmaxarray(float value, float *min, float *max);
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT