Using the following data to create various queries below.
Database is Pensacola Healthcare
Facility(FacilityID, SuborgID, Addr)
Provider(ProviderID, FirstName, LastName, NPI, FacilityID)
Patient(PatientID, FirstName, LastName, Addr)
Appointment (AppointmentID, ApptTime, ProviderID, PatientID, FacilityID)
1. Write a query displaying all patients
2. Write a query showing all appointments for a patient with an ID of 2.
3. Write a query in DESC order of Addr for all facilities.
4. Write a query showing all Providers with name LIKE Smith.
5. Write a query showing appointment and patient info for the patient with ID of 5 and AppointmentID of 21.
6. Create new table called SubOrg. Insert calues for SubOrgID, OrgID, and addr.
7. make an update query to facility table where ID of facility was 3 but now is 4.
8. Write a query showing an appointment for patient with ID of 5 and providerID of 7. Ensure to include patient.FirstName patient.Lastname provider.foirstName provider.lastName, PatientID, ProviderID, appointmentID and ApptTime. Hint use Inner Join query.
Hi,
Please find the queries as below:
(1) Select * from Patient;
(2) Select * from Appointment where PatientID = 2;
(3) Select * from Facility ORDER BY Addr DESC;
(4) Select * from Provider where FirstName LIKE '%Smith%' or
LastName LIKE '%Smith%';
(5) Select * from Appointment a,Patient p where p.PatientID = '5'
and a.AppointmentID = '21';
(6) CREATE TABLE SubOrg (
SubOrgID int,
OrgID int,
addr varchar(255));
Insert into SubOrg ( SubOrgID , OrgID , addr ) values (1,2, "New
Town City, LA");
(7) update Facility set FacilityID = 4 where FacilityID = 3;
(8) Select pa.FirstName, pa.Lastname, pr.FirstName, pr.LastName,
pa.PatientID, pr.ProviderID, a.AppointmentID , a.ApptTime from
Patient pa inner join Appointment a on pa.PatientID = a.PatientID
inner join Provider pr on pr.ProviderID = a.ProviderID where
a.PatientID = 5 and pr.ProviderID = 7;
Also, I am new to Chegg, this being my first answer, hence kindly
let me know if any more info is required for this answer.
Using the following data to create various queries below. Database is Pensacola Healthcare Facility(FacilityID, SuborgID, Addr)...
Create the database and tables
for the database. Show all SQL statements. Include primary and
foreign keys. Insert data into each table. Show select statements
and display the output of each table. Note:Student’s name must be
inserted into table as part of the data! Perform the SQL below:
Query one table and use WHERE to filter the results. The SELECT
clause should have a column list, not an asterisk (*). State the
purpose of the query; show the query and...
Consider EMPLOYEE database. Create the database and run the
following queries and write the result you get.
What would be the result of the following query (please create
the resulting table will all the columns and rows)?
SELECT
D.Dname, E.Lname, P.Pname
FROM
DEPARTMENT D, EMPLOYEE E, WORKS_ON W, PROJECT P
WHERE
D.Dnumber=E.Dno AND E.Ssn=W.Essn AND W.Pno=P.Pnumber
ORDER BY
D.Dname DESC,
E.Lname DESC;
Please help me on the SQL
queries, thank you so much.
Write a query to display the
title and publisher as well as the publisher contact for each book
using JOIN...USING clause.
Write a query to show the
first and last names of customers who have ordered cooking books.
Use the WHERE clause to join the tables.
Write a query to show the
title, cost and ISBN of each book in the books table. If the book
has been ordered,...
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...
Create a new database and execute the code below in SQL Server’s query window to create the database tables. CREATE TABLE PhysicianSpecialties (SpecialtyID integer, SpecialtyName varchar(50), CONSTRAINT PK_PhysicianSpecialties PRIMARY KEY (SpecialtyID)) go CREATE TABLE ZipCodes (ZipCode varchar(10), City varchar(50), State varchar(2), CONSTRAINT PK_ZipCodes PRIMARY KEY (ZipCode)) go CREATE TABLE PhysicianPractices (PracticeID integer, PracticeName varchar(50), Address_Line1 varchar(50), Address_Line2 varchar(50), ZipCode varchar(10), Phone varchar(14), Fax varchar(14), WebsiteURL varchar(50), CONSTRAINT PK_PhysicianPractices PRIMARY KEY (PracticeID), CONSTRAINT FK_PhysicianPractices_ZipCodes FOREIGN KEY (ZipCode) REFERENCES Zipcodes) go CREATE...
WRITING POSTGRESQL QUERIES RELATIONS: CREATE TABLE Movies( movieID INT, year INT UNIQUE, rating CHAR(1), length INT, totalEarned NUMERIC(7,2), PRIMARY KEY(movieID) ); CREATE TABLE Theaters( theaterID INT, address VARCHAR(40) UNIQUE, numSeats INT NOT NULL, PRIMARY KEY(theaterID) ); CREATE TABLE TheaterSeats( theaterID INT, seatNum INT, brokenSeat BOOLEAN NOT NULL, PRIMARY KEY(theaterID, seatNum), FOREIGN KEY(theaterID) REFERENCES Theaters ); CREATE TABLE Showings( theaterID INT, showingDate DATE, ...
SQL queries and procedures TABLE: Employees Business Rules: EmployeeID is defined as the primary key. Address has been denormalized to include City and State for performance reasons. DeptNbr is a foreign key that references DeptNbr in the Department table Manager is a foreign key that references EmployeeID in the Employees table Data Structure: (EmployeeId, LastName, FirstName, Street, City, State, Zip, DateOfHire, DateOfBirth, JobTitle, Salary, DeptNbr(fk), Manager(fk)) TABLE: Department Business Rules: DeptNbr is defined as the primary key. Data Structure: (DeptNbr,...
I am working on multi-table queries for my SQL class using a
premade database, which I have included screenshots of. I received
assistance and was able to complete a good number of the queries
but the bolded ones seem absolutely impossible to do??
How do I write a query for the bolded questions?? I've
scoured my textbook and notes and cannot get anything I try to
successfully produce results.
1. List all current reservations with the trip ID, customer’s
first...
SQL QUERIES
1) Using the Product and PC relations, create both tables in
your database and insert all the data. Show the SQL statements to
create each table and show a representative SQL insert statement
for the data in each table (i.e. you do not need to show insert
statements for all the data).
– For the remaining questions, assume that your SQL is part of
a program function and the function provides the input needed for
your SQL query....
Questions are based on the Northwind database.
a. A data dictionary (Excel file) that describes each of the
tables. (Attached in question)
b. Write good, clean SQL that answers the
following questions.
c. Separate your queries as I have
done in the following example. End each query with a semicolon (;)
and insert the word "go" between each query. Queries can span
multiple lines if required.
Select CustomerID from Customers;
go
Select Count(*) from Employees;
go
Select max(productID) from Products;
18. Produce...