Pre-Lab:: Experiment 7
Pre-Lab:: Experiment 7
PRE-LAB:
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;
Borrower Bank_ManagerLoan_Amount
Ramesh Sunderajan 10000.00
Suresh Ramgopal5000.00
Mahesh Sunderajan 7000.00
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
RECEPTIONISTDOCTOR NURSE
nid
did speci
rid 103
100 Anesthecian
104 107
101 Dentist
106 109
102 Cardiologist
108
105 Neurosurgeon
PATIENT
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:
Explanation
For Sample Case 0, we can get the following details:
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: