Question

I am using Oracle SQL and am new to it. I have seven tables, one of them is a subtable of two of the others. I need to do the following queries:

1. List all Patients and what Bed they are assigned to

2. List all patients who had Treatments and what Treatment they received

3. List all patients who had tests and what Test they had

4. List the employees (doctors, nurses, etc.) who assisted each patient.

5. List all patients in alphabetical order

6. List all patients who live in Atlanta and had a test completed

7. List all patients who live in either Woodstock or Roswell who had a treatment completed.

Can someone please show me theproper Oracle SQL syntax to pull these queries with the given tables i have?

Please note the Primary and Foreign keys in the tables, and that one table, Patient_Employee, is a subtable of the Patient table and the Employee table.

Here are pics to help you understand what i have:

Oracle SQL Develo : test Eile Edit View Navigate Run Versioning Iools Help θ G 网@ %E 咆 . O. 皛. ask test x test ▼ iorksheet Query Builder CREATE TABLE Patient Pat S3N nunber (9) HOT HULL, Bed_ID number (3] NOT NULL, Pat First None vrchar (S), Pat_Last Nene varchar (15), Pat_Phone nunber 15) Pat Street Addreaa varchar (25) Pat_City varchar 1s, Pat State varchar 15, Pat 2ip nuber ( Gender varchar (10) Pat Birth Dte DRTE Check In Date DATE Check Cut Date DTATE Insurance Provider varchar (15) PRDARY KEY (Pat_SsN, CONSTRAINT Bed-永FOREIGH KEY (Bed-TD) REFERENCES Bed (Bed-TD) INSERT INTO Patient VALUBS (666666666, ill, JeEf,Johnson, 6782224783, 93 Firat St. , Atlanta, -Georgia. 30405, Male, TO-DATE(1983-11-06, YYYY/MX/DD),TO_DATE (2018-10-06, YYYY/MX/DD), נת DATE (2018-10-06, TYYY/TI/DD ), Kaiser); INSERT 끄TTO Patient VALUES(777777777, 2ZZ, Chris, Patterson, 4703674628, Rosue 11, Georgio, 30186, .Mole, TO DATE(1990-01-17, YYYY/MH/DD), Τ0-DATEI. 2018-10-22., YYYY/MM/DD], TO DATE( 2018-10-23, /DD. Blue Cross INSERTINTO Patient VALUES (888888888, 177, Ee11Y, י smith. 40 4949 2408, 354 Third St. Woodstock. Georgia, 40897, Female, TO DATE (1992-01-17, YYYY/MX/DD), TO-DATE! 2018-10-22, YYYY/MM/DD), TO DATE( 2018-10-23, YYYY MADD), Blue Cross): INSERT 끄T0 Patient VALUES (999999999, 316, Preston, Mortis, 678 4647893, 18 Aclanta Georgi, 45326, Male, TO DATEl 1975-11-11, TYYYIM DD, TO DATE 2018-10-02, TYY?/M/DD. TO_DATE(2018-10-21, TTYIINDD)r Tricare Second St. rth St. , L Line 36 Column 1 Insert Modfied Windows: OR/LF Editing 11:07 PM 11/9/2018

Also, Here are SELECT * FROM queries of each table:

I didnt include the code for the Department table since it isnt necessary to perform any of the queries listed above. Please show me the proper syntax to make those queries specifically using Oracle SQL. Thanks in advance for the help!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. List all Patients and what Bed they are assigned to

select Pat_First_Name, Pat_Last_Name, Bed_Type from Patient p, Bed b where p.Bed_ID = b.Bed_ID;

2. List all patients who had Treatments and what Treatment they received

select Pat_First_Name , Pat_Last_Name, Treatment_Type , Treatment_Details from Patient p, Treatment t where t.Pat_SSN = p.Pat_SSN;

3.  List all patients who had tests and what Test they had

select Pat_First_Name, Pat_Last_Name, Test_Type, Test_Details from Diagnostic_Test t, Patient p where t.Pat_SSN = p.Pat_SSN;

4. List the employees (doctors, nurses, etc.) who assisted each patient.

select Emp_First_Name, Emp_Last_Name from Employee e, Patient_Employee pe where pe.Emp_SSN = e.Emp_SSN;

5. List all patients in alphabetical order

select * from Patients order by Pat_First_Name, Pat_Last_Name;

6. List all patients who live in Atlanta and had a test completed

select Pat_First_Name, Pat_Last_Name from Patient p, Diagnostic_Test t where p.Pat_SSN = t.Pat_SSN and lower(p.Pat_City) = 'atlanta' and p.check_out_date is not null;

7. List all patients who live in either Woodstock or Roswell who had a treatment completed.

select Pat_First_Name , Pat_Last_Name from Patient p, Treatment t where p.Pat_SSN = t.Pat_SSN and lower(p.Pat_City) in ('woodstock','rosewell') and p.check_out_date is not null;

Add a comment
Know the answer?
Add Answer to:
I am using Oracle SQL and am new to it. I have seven tables, one of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I am using oracle sql developer to create some queries to generated reports and it is...

    I am using oracle sql developer to create some queries to generated reports and it is not working. I am not sure how to use count, group by, and order by. Help me fix my query and explain to me how you did, so can do it next time. Also, I have to convert this query to a stored procedure, so can you help me do it too? Here is my query: SELECT COUNT(GUEST.FIRSTNAME), GUEST.FIRSTNAME, GUEST.LASTNAME, GUEST.GUESTTYPE, RESERVATION.RESERVATIONDATE, GUEST.EMAIL, FROM...

  • Database For this lab you will be using SQL SELECT statements to query your database tables....

    Database For this lab you will be using SQL SELECT statements to query your database tables. You will be turning in the results of the following queries: 1. List all Patients and what Bed they are assigned to 2. List all patients who had Treatments and what Treatment they received 3. List all patients who had tests and what Test they had 4. List the employees (doctors, nurses, etc.) who assisted each patient. 5. List all patients in alphabetical order...

  • SQL: CREATE STATEMENT For patients whose last name matches the name entered by the user, display...

    SQL: CREATE STATEMENT For patients whose last name matches the name entered by the user, display their first name, phone number, and doctor's name. Note: Try Davis. (TEXT FOR DATABASE BELOW) DROP TABLE PATIENT; DROP TABLE BILLING; DROP TABLE DOCTOR; CREATE TABLE DOCTOR( DOC_ID VARCHAR2(10) NOT NULL, DOC_NAME VARCHAR2(20), DATEHIRED DATE, SALPERMON NUMBER(8), AREA VARCHAR2(20), SUPERVISOR_ID NUMBER(8), CHGPERAPPT NUMBER(8), ANNUAL_BONUS NUMBER(8), PRIMARY KEY (DOC_ID) ); INSERT INTO DOCTOR VALUES('432', 'Harrison', to_date('05-DEC-1994','dd-mon-yyyy'), 12000, 'Pediatrics', 100, 75, 4500); INSERT INTO DOCTOR VALUES('509',...

  • SQL - create statement for query For each patient, display his or her last name, first...

    SQL - create statement for query For each patient, display his or her last name, first name, and the name of his or her doctor. For each pediatrics patient, display his or her ID and his or her doctor's ID and name. For each doctor, display the name and the name of the doctor's supervisor in alphabetic order of supervisor's name. Include column aliases for clarity. Note: Check for accuracy. For each doctor in one of the two areas entered...

  • Using Oracle database Need help getting the JAVA code for the queries and the rest of...

    Using Oracle database Need help getting the JAVA code for the queries and the rest of the instructions. Need the table provided converted and fulfil  the requirements. . For this project - you will be writing a program (you may choose whatever programming language you want) to read in your database tables from Lab 5, and then print out the contents of each of the tables. Additionally, you must print at least one query each with the following clauses: *JOIN (any...

  • Q2. Retrieve the names of all employees from the employee table to produce output on CSV...

    Q2. Retrieve the names of all employees from the employee table to produce output on CSV format or delimited format with a common delimeter, rather than separete columns. Hint:Put the whole row into a string with a semicolon as the seperator(delimeter) between thecolumns: FORMAT:(fname;minit;lname) Example: EMPLOYEES -------------- James;E;Borg Frank;T;Wong Q3. Write a query to show the employees name from the employee table in this format: first letter of the first name, followed by a dot, a blank, and the full...

  • Oracle 12c SQL Chapter 12 Determine which orders were shipped to the same state as order...

    Oracle 12c SQL Chapter 12 Determine which orders were shipped to the same state as order 1014. CREATE TABLE Orders (Order# NUMBER(4), Customer# NUMBER(4), OrderDate DATE NOT NULL, ShipDate DATE, ShipStreet VARCHAR2(18), ShipCity VARCHAR2(15), ShipState VARCHAR2(2), ShipZip VARCHAR2(5), ShipCost NUMBER(4,2), CONSTRAINT orders_order#_pk PRIMARY KEY(order#), CONSTRAINT orders_customer#_fk FOREIGN KEY (customer#) REFERENCES customers(customer#)); INSERT INTO ORDERS VALUES (1000,1005,TO_DATE('31-MAR-09','DD-MON-YY'),TO_DATE('02-APR-09','DD-MON-YY'),'1201 ORANGE AVE', 'SEATTLE', 'WA', '98114' , 2.00); INSERT INTO ORDERS VALUES (1001,1010,TO_DATE('31-MAR-09','DD-MON-YY'),TO_DATE('01-APR-09','DD-MON-YY'), '114 EAST SAVANNAH', 'ATLANTA', 'GA', '30314', 3.00); INSERT INTO ORDERS VALUES (1002,1011,TO_DATE('31-MAR-09','DD-MON-YY'),TO_DATE('01-APR-09','DD-MON-YY'),'58...

  • Using the code below in Oracle SQL Live I keep getting an error message for the...

    Using the code below in Oracle SQL Live I keep getting an error message for the last 4 INSERTS. The error message is: ORA-00932: inconsistent datatypes: expected DATE got NUMBER. How do I correct that error? CREATE TABLE BASE ( BASENUM CHARACTER(3) NOT NULL, BASECITY varchar(20), BASESTATE CHARACTER(2), BASEPHON varchar(10), BASEMGR varchar(10), PRIMARY KEY (BASENUM) ); CREATE TABLE TYPE ( TYPENUM CHARACTER(1) NOT NULL, TYPEDESC varchar(30), PRIMARY KEY (TYPENUM) ); CREATE TABLE TRUCK ( TNUM CHARACTER(4) NOT NULL, BASENUM CHARACTER(3),...

  • Oracle only database: DROP TABLE ORDERITEMS; DROP TABLE Orders; DROP TABLE BOOKAUTHOR; DRO...

    oracle only database: DROP TABLE ORDERITEMS; DROP TABLE Orders; DROP TABLE BOOKAUTHOR; DROP TABLE BOOKS; DROP TABLE PROMOTION; DROP TABLE AUTHOR; DROP TABLE CUSTOMERS; DROP TABLE PUBLISHER; CREATE TABLE Customers ( Customer# NUMBER(4), LastName VARCHAR2(10) NOT NULL, FirstName VARCHAR2(10) NOT NULL, Email VARCHAR(40), Address VARCHAR2(20), City VARCHAR2(12), State VARCHAR2(2), Zip VARCHAR2(5), Referred NUMBER(4), Region CHAR(2), CONSTRAINT customers_customer#_pk PRIMARY KEY(customer#) ); INSERT INTO CUSTOMERS VALUES (1001, 'MORALES', 'BONITA', '[email protected]', 'P.O. BOX 651', 'EASTPOINT', 'FL', '32328', NULL, 'SE'); INSERT INTO CUSTOMERS VALUES...

  • 1.) Using MS SSMS, create a new query file (sql) and write and execute SQL statements...

    1.) Using MS SSMS, create a new query file (sql) and write and execute SQL statements to insert at least five records in each table, preserving all constraints. Put in enough data to demonstrate how the database will function [name the file PopulateDBWithData.sql]. 2.) Using MS SSMS, create a new query file (sql) and write SQL statements that will process five non-routine requests for information from the database just created. For each, write the request in English (using the --...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT