0% found this document useful (0 votes)
211 views

Pre-Lab:: Experiment 7

1. The document describes an experiment involving SQL queries on a case study about an emergency room information system. 2. It includes pre-lab questions about SQL concepts and queries. 3. The in-lab section describes tables that were created for the case study including tables for employees, doctors, nurses, patients, prescriptions, appointments, and more.

Uploaded by

likhith chowdary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
211 views

Pre-Lab:: Experiment 7

1. The document describes an experiment involving SQL queries on a case study about an emergency room information system. 2. It includes pre-lab questions about SQL concepts and queries. 3. The in-lab section describes tables that were created for the case study including tables for employees, doctors, nurses, patients, prescriptions, appointments, and more.

Uploaded by

likhith chowdary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

EXPERIMENT 7

Implement SQL Queries on Case Study 2 (EMERGENCY ROOM INFORMATION SYSTEM)

PRE-LAB:

1) What is the output of following query


SELECT A.id FROM A WHERE A.age> ALL (SELECT B.age FROM B
WHERE B. name = "ABC")

2) What is the purpose of WHERE Clause in mysql?

3) Differentiate between AND, OR and NOT operators in mysql

4) Consider a database table T containing two columns X and Y each of type integer. After
the creation of the table, one record (X=1, Y=1) is inserted in the table. Let MX and My
denote the respective maximum values of X and Y among all records in the table at any point
in time. Using MX and MY, new records are inserted in the table 128 times with X and Y
values being MX+1, 2*MY+1 respectively. It may be noted that each time after the insertion,
values of MX and MY change. What will be the output of the following SQL query after the
steps mentioned above are carried out? [) Consider a database table T containing two
columns X and Y each of type integer. After the creation of the table, one record (X=1, Y=1)
is inserted in the table. Let MX and My denote the respective maximum values of X and Y
among all records in the table at any point in time. Using MX and MY, new records are
inserted in the table 128 times with X and Y values being MX+1, 2*MY+1 respectively. It
may be noted that each time after the insertion, values of MX and MY change. What will be
the output of the following SQL query after the steps mentioned above are carried out?
SELECT Y FROM T WHERE X=7;

5) Database table by name Loan_Records is given below.

Borrower Bank_ManagerLoan_Amount
Ramesh Sunderajan 10000.00
Suresh Ramgopal5000.00
Mahesh Sunderajan 7000.00

What is the output of the following SQL query?

SELECT Count(*)
FROM ( (SELECT Borrower, Bank_Manager
FROM Loan_Records) AS S
NATURAL JOIN (SELECT Bank_Manager,
Loan_Amount
FROM Loan_Records) AS T );

1) How can you separate the Rename and the Alias operations?
2) State thedifference between (Null Value Function) nvl() & Coalesce().
IN-LAB:

EMPLOYEE

wid fname lname email phno address


[email protected] 998877665
100 Arun Kumar m 5 Hyderabad
998763456 Secunderaba
101 David Raju [email protected] 7 d
[email protected] 998649247
102 Harish Reddy m 9 Bowenpally
998535039
103 John Samuel [email protected] 1 Hyderabad
998420830
104 Kira Kumar [email protected] 3 Amaravathi
Aravin [email protected] 998306621
105 d Babu m 5 Guntur
Pravee [email protected] 998192412
106 n Kumar m 7 Tullur
Rames 998078203
107 h Kumar [email protected] 9 Mangalagiri
[email protected] 997963995
108 Jayanth Kumar m 1 Vijayawada
997849786
109 Eswar Raju [email protected] 3 Hyderabad

RECEPTIONISTDOCTOR NURSE

nid
did speci
rid 103
100 Anesthecian
104 107
101 Dentist
106 109
102 Cardiologist
108
105 Neurosurgeon

PATIENT

pid fname lname email phno address Date_adm


n

200 David Samson [email protected] 765432897 Mumbai 13-10-2019


6
201 Bharath Kumar [email protected] 876543890 Hyderabad 22-01-2020
7
202 Eswar Prasad [email protected] 987654883 Vijayawada 15-03-2020
8
203 Jaya Laxmi [email protected] 876548976 Delhi 06-07-2020
5
204 Laxmi Devi [email protected] 765443069 Mumbai 12-03-2020
2
205 Pramod Reddy [email protected] 654337161 Hyderabad 05-02-2020
9
206 Charan Kumar [email protected] 543231254 Vijayawada 22-04-2020
6
207 Kalyan Reddy [email protected] 432125347 Delhi 10-07-2020
3
208 Rajesh Yadav [email protected] 321019440 Chennai 03-03-2020
m 0
209 Naveen Kumar [email protected] 209913532 Hyderabad 22-04-2020
7

PRESCRIPTIONPCASE
bednu
qtyperda
name dose y
m pid
20 200
bacd once 2ml
21 201
xyz twice 4ml
22 202
pqr thrice 100mg
23 203
SHIFT 24 204
25 205
triagedocto starttim endtim 26 206
r day e e 27 207
100 12-04-2020 9 5 28 208
101 20-06-2020 4 8 29 209
102 01-08-2020 6 12
105 05-08-2020 13 18

APPOINTMENT

pid amt
200 200
201 200
202 300
203 600
204 200
205 300
206 200
207 200
208 200
209 600

1) Create the database in mysql and create the necessary tables for the given case study
using appropriate keys and relationships between the tables
2) Insert atleast 10 records into every table that is implemented in the case study
3) Write an MYSQL query to add columns actiontaken and personell to the table case?
4) Write an MYSQL query to display who are patients required to stay in the hospital?
5) Write an MYSQL query to display who paid amount between 1000 and 3000 for the
appointment
6) Write an MYSQLquery to update the value of phno of WID=12 of worker table
7) Write an MYSQL query to truncate the values of appointment table
8) Write an MYSQL query to calculate average amount of appointment.
9) Write an MYSQL query to display patient number in descending order
10) Write an MYSQL query to display bed number of patient with least patient id.
11) Write query for creating view from patient table.
12) Write a MYSQL query to update view the Patientview where patientid>3 by using
replace view statement
13) Display the patient date of joining into format “dd month yyyy’ for example as “24
March 2020”
14) Display the patient joining time in 24 hour format. For eg: 3:30pm should be displayed as
15:30
15) Write a MYSQL query to display count of patients who come from same city.
16) Write an MYSQLquery to first name of patient who admitted and allotted the bed
POST-LAB:

1) Julia asked her students to create some coding challenges. Write a query to print
the hacker_id, name, and the total number of challenges created by each student. Sort your
results by the total number of challenges in descending order. If more than one student
created the same number of challenges, then sort the result by hacker_id. If more than one
student created the same number of challenges and the count is less than the maximum
number of challenges created, then exclude those students from the result.
Input Format
The following tables contain challenge data:

 Hackers: The hacker_id is the id of the hacker, and name is the name of the hacker.


 Challenges: The challenge_id is the id of the challenge, and hacker_id is the id of the
student who created thechallenge

Explanation
For Sample Case 0, we can get the following details:

Students  and  both created  challenges, but the maximum number of challenges created is  so


these students are excluded from the result.
For Sample Case 1, we can get the following details:
Students 12299 and 34856 both created 6 challenges. Because 6 is the maximum number of
challenges created, these students are included in the result.

2) Query all columns for all American cities in the CITY table with populations larger
than 100000. The CountryCode for America is USA.The CITY table is described as follows:

You might also like