Question

In: Computer Science

There are 4 tables as shown below: Claims, defendants, Events and statuscodes. Claims: claim_id patient_name =====================...

There are 4 tables as shown below: Claims, defendants, Events and statuscodes.
Claims:
claim_id patient_name
=====================
10 'Smith'
20 'Jones'
30 'Brown'
Defendants
claim_id defendant_name
=======================
10 'Johnson'
10 'Meyer'
10 'Dow'
20 'Baker'
20 'Meyer'
30 'Johnson'
Events:
claim_id defendant_name claim_status change_date
==================================================
10 'Johnson' 'AP' '1994-01-01'
10 'Johnson' 'OR' '1994-02-01'
10 'Johnson' 'SF' '1994-03-01'
10 'Johnson' 'CL' '1994-04-01'
10 'Meyer' 'AP' '1994-01-01'
10 'Meyer' 'OR' '1994-02-01'10
10 'Meyer' 'SF' '1994-03-01'
10 'Dow' 'AP' '1994-01-01'
10 'Dow' 'OR' '1994-02-01'
20 'Meyer' 'AP' '1994-01-01'
20 'Meyer' 'OR' '1994-02-01'
20 'Baker' 'AP' '1994-01-01'
30 'Johnson' 'AP' '1994-01-01'
StatusCodes
claim_status claim_status_desc claim_seq
========================================
'AP' 'Awaiting review panel' 1
'OR' 'Panel opinion rendered' 2
'SF' 'Suit filed' 3
'CL' 'Closed' 4
The claim status of a defendant (with regard to a given claim) is his or her latest claim status, which is the claim status with the highest claim sequence number.
The claim status of a claim is the claim status of the defendant having the lowest claim status of all the defendants involved in the claim. This makes the claim status a minimum of the maximums. For this sample data, the answer would be:
claim_id patient_name claim_status
==================================
10 'Smith' 'OR'
20 'Jones' 'AP'
30 'Brown' 'AP'
The problem is to write a sql query to find the claim status of each claim and display it.

Solutions

Expert Solution

Solution

First we need to Create 4 tables one by one

SQL statements for creating this

CREATE TABLE claims (claim_id NUMBER, patient_name VARCHAR2(20));
INSERT INTO claims VALUES (10,'Smith');
INSERT INTO claims VALUES (20,'Jones');
INSERT INTO claims VALUES (30,'Brown');

---

CREATE TABLE defendants (claim_id NUMBER, defendant_name VARCHAR2(20));
INSERT INTO defendants VALUES(10,'Johnson' );
INSERT INTO defendants VALUES(10,'Meyer' );
INSERT INTO defendants VALUES(10,'Dow' );
INSERT INTO defendants VALUES(20,'Baker' );
INSERT INTO defendants VALUES(20,'Meyer' );
INSERT INTO defendants VALUES(30,'Johnson' );

---

CREATE TABLE legalevents (claim_id NUMBER, defendant_name VARCHAR2(20), claim_status VARCHAR2(2), change_date DATE);
INSERT INTO legalevents VALUES (10,'Johnson' ,'AP' , '1994-01-01');
INSERT INTO legalevents VALUES (10,'Johnson' ,'OR' , '1994-02-01');
INSERT INTO legalevents VALUES (10,'Johnson' ,'SF' , '1994-03-01');
INSERT INTO legalevents VALUES (10,'Johnson' ,'CL' , '1994-04-01');
INSERT INTO legalevents VALUES (10,'Meyer' ,'AP' , '1994-01-01');
INSERT INTO legalevents VALUES (10,'Meyer' ,'OR' , '1994-02-01');
INSERT INTO legalevents VALUES (10,'Meyer' ,'SF' , '1994-03-01');
INSERT INTO legalevents VALUES (10,'Dow' ,'AP' , '1994-01-01');
INSERT INTO legalevents VALUES (10,'Dow' ,'OR' , '1994-02-01');
INSERT INTO legalevents VALUES (20,'Meyer' ,'AP' , '1994-01-01');
INSERT INTO legalevents VALUES (20,'Meyer' ,'OR' , '1994-02-01');
INSERT INTO legalevents VALUES (20,'Baker' ,'AP' , '1994-01-01');
INSERT INTO legalevents VALUES (30,'Johnson' ,'AP' , '1994-01-01');


CREATE TABLE claimStatusCodes (claim_status VARCHAR2(2), claim_status_desc VARCHAR2(40), claim_seq NUMBER);
INSERT INTO claimstatuscodes VALUES ('AP','Awaiting review panel' , 1);
INSERT INTO claimstatuscodes VALUES ('OR','Panel opinion rendered', 2);
INSERT INTO claimstatuscodes VALUES ('SF','Suit filed' , 3);
INSERT INTO claimstatuscodes VALUES ('CL','Closed' , 4);

---

Answer to the Problem

Screenshot

SQL query

SELECT a.claim_id,patient_name,claim_status
FROM (SELECT claim_id,MIN(claim_seq) AS min_claim_seq
FROM (SELECT claim_id,defendant_name,MAX(claim_seq) AS claim_seq
FROM legalevents le, claimstatuscodes cs
WHERE le.claim_status= cs.claim_status
GROUP BY claim_id,defendant_name
)
GROUP BY claim_id
) a
,claims cl
,claimstatuscodes cs
WHERE a.claim_id= cl.claim_id
AND a.min_claim_seq = cs.claim_seq;

Result of the Query

Complete screenshot of the SQL query

---

Answered and given complete query also

all the best

please upvote


Related Solutions

4/ You are operating a fan with the characteristics shown in the figure below. The 25...
4/ You are operating a fan with the characteristics shown in the figure below. The 25 kW fan currently operates continuously at full speed with the flow reduced to 90% of its rated capacity using downstream dampers. An evaluation reveals that there is inadequate fresh air being introduced into the building during the day, and too much is supplied at night. The flow rate needs to increase to 100% from 7am to 7pm, and can be reduced to 50% at...
Draw the decision tables for all the problems below For the decision tables above, reduce the...
Draw the decision tables for all the problems below For the decision tables above, reduce the tables if possible. Problems A month is to be represented as an integer. A valid month is in the range of 1..12. An integer < 1 is invalid, or an integer > 12 is invalid. Consider how this can be simplified or reduced. An employee is either hourly or salaried. An hourly employee is paid by calculating an hourly wage and an hourly employee...
please provide me below just i want z tables , t tables , chi square tables...
please provide me below just i want z tables , t tables , chi square tables both right tailed ,left tailed .,two tailed high quality of images only,other wise it wont help me, it leads thumbdown. thankyou chegg
For the data set shown below, complete parts (a) through (d). X Y 3 4 4...
For the data set shown below, complete parts (a) through (d). X Y 3 4 4 7 5 6 7 12 8 15 (a) Find the estimates of Bo and B1. Bo=bo= _____ (Round to three decimal places as needed.) B1=b1= ______(Round to four decimal places as needed.) (b) Compute the standard error the point estimate for se= ____ (c) Assuming the residuals are normally distributed, determine Sb1=____ (Round to four decimal places as needed.) (d) Assuming the residuals are...
For the data set shown below, complete parts (a) through (d) below. X 3 4 5...
For the data set shown below, complete parts (a) through (d) below. X 3 4 5 7 8 Y 3 5 8 12 13 (a) Find the estimates of Bo and B1. Bo=bo= _____ (Round to three decimal places as needed.) B1=b1= ______(Round to four decimal places as needed.) (b) Compute the standard error the point estimate for se= ____ (c) Assuming the residuals are normally distributed, determine Sb1=____ (Round to four decimal places as needed.) (d) Assuming the residuals...
For the data set shown below, complete parts (a) through (d) below. X 3 4 5...
For the data set shown below, complete parts (a) through (d) below. X 3 4 5 7 8 Y 4 7 6 12 15 (a) Find the estimates of Bo and B1. Bo=bo= _____ (Round to three decimal places as needed.) B1=b1= ______(Round to four decimal places as needed.) (b) Compute the standard error the point estimate for se= ____ (c) Assuming the residuals are normally distributed, determine Sb1=____ (Round to four decimal places as needed.) (d) Assuming the residuals...
4. Click on the link shown below, then prepare a paper on the Hawthorne studies. What...
4. Click on the link shown below, then prepare a paper on the Hawthorne studies. What was the original research question or premise? What type of studies was conducted? What were the final results of the studies? What might other variations of the studies have been conducted? http://www.saylor.org/site/wp-content/uploads/2013/01/BUS209-1.2-HawthorneStudies.pdf
SquerDeal Mfg manufactures tables and desks, which are sold in sets of 4 chairs to tables...
SquerDeal Mfg manufactures tables and desks, which are sold in sets of 4 chairs to tables to bussiness, school, and public facilities. They reported the fallowing financial information for last year: Direct Labor 20,000hrs @$15/hr, production Manager Salary $80,000, Factory Rent $60,000, Equipment Maintenance$5,000(considered a variable expense), Equipment Depreciation $25,000, Production for the year 35,000 units, Total Revenue $12,000,000, Total table and chairs set sold during the period 30,000, Operating Income under absorption costing (after non-production expenses) $5,000,000 what would...
4.Consider events A and B, neither of which are impossible events. Prove the following statements. A)(4...
4.Consider events A and B, neither of which are impossible events. Prove the following statements. A)? ? ? = 1 − ?(?|?) B)If ? ? ? ? = ? ? ∩ ? , then A and B must be independent events.
For the data set shown​ below. x   y 3   4 4   5 5   8 7   12...
For the data set shown​ below. x   y 3   4 4   5 5   8 7   12 8   15 Find the estimates of β0 and β1. β0≈b0=-3.256 ​ (Round to three decimal places as​ needed.) β1≈b1=2.233 (Round to three decimal places as​ needed.) (b) Compute the standard​ error, the point estimate for σ. Se=0.5972 ​(Round to four decimal places as​ needed.) ​(c) Assuming the residuals are normally​ distributed, determine sb1. sb1=0.144 ​(Round to three decimal places as​ needed.) ​(d) Assuming the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT