Question

In: Computer Science

Provider Department Hospitalization MaxAmount MinAmount Pro1 Dep1 12 12 10 Pro1 Dep1 10 12 10 Pro1...

Provider Department Hospitalization MaxAmount MinAmount
Pro1 Dep1 12 12 10
Pro1 Dep1 10 12 10
Pro1 Dep1 11 12 10
Pro2 Dep2 22 32 19
Pro2 Dep2 32 32 19
Pro2 Dep2 19 32 19
Pro3 Dep3 34 34 10
Pro3 Dep3 10 34 10
Pro3 Dep3 17 34 10
Pro4 Dep4 23 23 23

Using Windows Functions

a) Write a query that will produce the table above as an outcome

b) Why are all the values equal in the last tuple of the table

c) Write a second query that will add a column to the table that will also provide the max amount of hospitalization for all providers.

Solutions

Expert Solution

Considering this table as Table2, parent table of Table2 is Table1 and child table of Table2 is Table3.

(A)

SELECT Provider, Department, Hospitalization,MAX(Hospitalization) Over(PARTITION BY Department ORDER BY provider) AS MaxAmount, MIN(Hospitalization) Over(PARTITION BY Department ORDER BY provider) AS MinAmount

FROM Table1

Where Provider = 'Pro1' AND Department= 'Dep1' OR Provider = 'Pro2' AND Department= 'Dep2' OR Provider = 'Pro3' AND Department= 'Dep3' OR Provider = 'Pro4' AND Department= 'Dep4';

(B) Why are all the values equal in the last tuple of the table

Because for last tuple, their is only one entry in the parent table where

Provider Department Hospitalization
Pro4 Dep4

23

so, for single entry minimum andd maximum value will alway same .

ie. MIN(Hospitalization) = 23 = MAX(Hospitalization) = Hospitalization value of Dep4 and Pro4

(C) Write a second query that will add a column to the table that will also provide the max amount of hospitalization for all providers.

ALTER TABLE Table2 ADD Maximum_Amount NUMBER;

SELECT Provider, Department, Hospitalization,MAX(Hospitalization) Over(PARTITION BY Department ORDER BY provider) AS MaxAmount, MIN(Hospitalization) Over(PARTITION BY Department ORDER BY provider) AS MinAmount, MAX(Hospitalization) AS Maximum_Amount

FROM Table1

Where Provider = 'Pro1' AND Department= 'Dep1' OR Provider = 'Pro2' AND Department= 'Dep2' OR Provider = 'Pro3' AND Department= 'Dep3' OR Provider = 'Pro4' AND Department= 'Dep4';


Related Solutions

what is bad hospitalization?
what is bad hospitalization?
You are a provider working in a clinic or emergency department (ED) and a patient you...
You are a provider working in a clinic or emergency department (ED) and a patient you have not seen before comes in complaining of chronic pain and in need of a refill of a narcotic pain medication. This patient is visiting from across the country and cannot get a refill. How will you use communication to determine the best approach to assessing this patient’s request? Also, provide the difference between a living will and advance directives. Are they honored nationwide...
Picture Arrangement Scores Left-Handed: 12, 10, 12, 14, 12, 10, 8.13,7 Right-Handed: 8, 10, 10, 12,...
Picture Arrangement Scores Left-Handed: 12, 10, 12, 14, 12, 10, 8.13,7 Right-Handed: 8, 10, 10, 12, 11, 6, 7,9,11    •   Is there a significant difference in the Picture Arrangement scores between the right- and left-handed students? Use α = .05 in making your decision. Be sure to state your hypotheses in symbols and use subscripts to denote each group e.g., and to represent the true population mean Picture Arrangement score for right- and left-handed students, respectively. Include the following...
Common Fears/Concerns during Hospitalization and Important Safety Measures During Hospitalization for: infants (1st year) toddlers(1-3 years)preschool...
Common Fears/Concerns during Hospitalization and Important Safety Measures During Hospitalization for: infants (1st year) toddlers(1-3 years)preschool (4-6 years) school age (7-11 years) adolescence ( 12-18 years). Thank you in advance!
Determine the OH−] , pH, and pOH of a solution with a [H+] of 8.0×10−12 M8.0×10−12...
Determine the OH−] , pH, and pOH of a solution with a [H+] of 8.0×10−12 M8.0×10−12 M at 25 °C. [OH−]= pH= pOH= Determine the [H+] , pH, and pOH of a solution with an [OH−] of 0.00024 M0.00024 M at 25 °C. [H+]= pH= pOH= Determine the [H+] , [OH−] , and pOH of a solution with a pH of 10.4710.47 at 25 °C. [H+]= [OH−]= pOH= Determine the [H+] , [OH−] , and pH of a solution with...
11 12 11 10 14 15 16 12 11 10 12 20 13 32 35 14...
11 12 11 10 14 15 16 12 11 10 12 20 13 32 35 14 41 12 10 11 12 12 13 16 14 17 18 19 12 13 14 10 10 14 11 10 12 14 12 13 16 14 17 19 20 15 25 15 45 45 44 41 40 14 18 19 24 20 26 36 34 30 31 50 15 12 Find the following: Mean? (1) Median (2), and Mode? Find : Q3, Q1, D7,...
You are the manager of a cardiology department with 10 general cardiologists. The department performs approximately...
You are the manager of a cardiology department with 10 general cardiologists. The department performs approximately 6000 EKG’s annually. They currently have 4 EKG machines; 2 are 10 years old and fully depreciated and the other 2 are 6 years old and will be fully depreciated in one year. None are integrated with their EHR so the staff needs to scan the results into the EHR and the billing has to be done manually. As manager, you believe that purchasing...
Discuss nursing interventions that minimize the fear of bodily injury during hospitalization.
Discuss nursing interventions that minimize the fear of bodily injury during hospitalization.
In 10 test runs, a truck operated for 8, 10, 10, 7, 9, 12, 10, 8,...
In 10 test runs, a truck operated for 8, 10, 10, 7, 9, 12, 10, 8, 7, and 9 miles with one gallon of a certain gasoline. Is this evidence at the 0.05 level of signifcance that the truck is not operating at an average of 11.5 miles per gallon with this gasoline? What assumptions must be satised in order for the procedure you used to analyze these data to be valid?
12. EX.17-12.ALGO Cost of Units Completed and in Process The charges to Work in Process—Assembly Department...
12. EX.17-12.ALGO Cost of Units Completed and in Process The charges to Work in Process—Assembly Department for a period, together with information concerning production, are as follows. All direct materials are placed in process at the beginning of production. Work in Process—Assembly Department Bal., 3,000 units, 50% completed 7,350 To Finished Goods, 69,000 units ? Direct materials, 71,000 units @ $1.3 92,300 Direct labor 126,000 Factory overhead 49,000 Bal. ? units, 50% completed ? Cost per equivalent units of $1.30...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT