Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

LEAD – SQL ASSESSMENT TEST Marks :50

Time : 3hrs

I. Answer the following questions: 5*1 =5

1. What is returned by SUBSTR(‘Oracle Functions’, -1, 1)?

2. Which of the following is true about removing rows from a table?


A - You remove existing rows from a table using the DELETE statement
B - No rows are deleted if you omit the WHERE clause.
C - You cannot delete rows based on values from another table.
D - All of the above.
3. Which of the following is not true about a FOREIGN KEY constraint?
A - It is a referential integrity constraint.
B - It establishes a relationship between a primary key or a unique key in the same table or a
different table.
C - A foreign key value cannot be null.
D - A foreign key value must match an existing value in the parent table.

4. Which SQL keyword is used to retrieve only unique values ?


DISTINCT
DIFFERENT
UNIQUE
DISTINCTIVE

5. Which of the following is illegal ?


SELECT SYSDATE - (SYSDATE - 2) FROM DUAL;
SELECT SYSDATE - (SYSDATE + 2) FROM DUAL;
SELECT SYSDATE - SYSDATE FROM DUAL;
None of the above

II. Answer the following 10*3=30

1. Explain the different methods/ Syntax to insert the records in to a table.

2. Update the patients table for the allergies column. If the patient's allergies is null then replace it with
'NKA'

3. Show how many patients have a birth_date with 2010 as the birth year.

4. Show the first_name, last_name, and height of the patient with the greatest height.

5. Show all columns for patients those who have patient_ids are in even number

6. Show patient details(patient name, gender, diagnosis, no. of times came for the dignosis) those who
came for same diagnosis multiple times

7. Show patient_id and first_name from patients where their first_name start and ends with 's' and is at
least 6 characters long.

8. Show firstname, last name , role from patients and Doctors table

Role should be “Patient” if data is from Patient table


Role should be “Doctor” if data is from Doctors table.

9. Show first_name, last_name, and the total number of admissions attended for each doctor.

10. For each doctor, display their id, full name, and the first and last admission date they attended.

III. Answer the following 5*3=15

1. All patients who have gone through admissions, can see their medical documents on our site. Those
patients are given a temporary password after their first admission. Show the patient_id and
temp_password.
The password must be the following, in order:
1. patient_id
2. the numerical length of patient's last_name
3. year of patient's birth_date

2. a. Show the percent of patients Gender

b. We need a breakdown for the total amount of admissions each doctor has started each year. Show the
doctor_id, doctor_full_name, specialty, year, total_admissions for that year.

3. We are looking for a specific patient. Pull all columns for the patient who matches the following criteria:
- First_name contains an 'r' after the first two letters.
- Identifies their gender as 'F'
- Born in February, May, or December
- Their weight would be between 60kg and 80kg
- Their patient_id is an odd number
- They are from the city 'Kingston'

You might also like