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

Assignment - 2: Database

The document provides 10 SQL queries to retrieve information from database tables for patients, doctors, and bills. The queries include finding doctor details without patients, listing patient details and discounted bills, finding details of a specific doctor's patients, and more.

Uploaded by

Devendra Patil
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Assignment - 2: Database

The document provides 10 SQL queries to retrieve information from database tables for patients, doctors, and bills. The queries include finding doctor details without patients, listing patient details and discounted bills, finding details of a specific doctor's patients, and more.

Uploaded by

Devendra Patil
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 5

Assignment - 2

DATABASE-

1. List the doctors names and specialization those have no patient allotted.

QUERY- SELECT name,specialization


FROM doctor
WHERE dr_id NOT IN (SELECT DISTINCT dr_id FROM patient);

2.

List all details of patient table and bill amount in increasing order with the concession
of 10%.

QUERY- SELECT patient.*,amount*(0.9)


FROM patient,bill
WHERE pat_id=patid
ORDER by amount;

3. Find all the name, age, address, mobile of Dr. D. S. Baharani patient.

QUERY- SELECT name,age,address,mobile


FROM patient
WHERE dr_id IN
(SELECT dr_id FROM doctor WHERE name="Dr. D. S. Baharani");

4. Find the patient name, age, gender, address and doctor name who suffered from
Heart problem.

QUERY- SELECT patient.name,age,patient.gender,patient.address,doctor.name


FROM patient,doctor
WHERE diagnosis="Heart problem" AND doctor.dr_id=patient.dr_id;

5.Find the doctors detail whose address has the substring as “town”.
QUERY- SELECT *
FROM doctor
WHERE address LIKE "%town%";

6. Find the patient name, age, address, diagnosis, doctor name order by doctor name.

QUERY- SELECT patient.name,age,patient.address,diagnosis,doctor.name AS


doctor_name
FROM patient,doctor
WHERE patient.dr_id=doctor.dr_id
ORDER BY doctor.name;

7.

Find the patient details with bill amount greater than 7000 in ascending order.

QUERY- SELECT patient.*,amount


FROM patient,bill
WHERE amount>7000
AND pat_id=patid;
8. Update the bill amount of all the patient with 10% discount if bill amount is greater
than 10000.

QUERY- UPDATE bill SET amount=amount*(0.9) WHERE amount>7000;

9.Change the patient table gender column data type as varchar(1).

QUERY- ALTER TABLE patient MODIFY COLUMN gender VARCHAR(1);


10. Find all the patient whose bill amount is greater than the average bill amount.

QUERY- SELECT patient.*,amount


FROM patient,bill
WHERE pat_id=patid AND amount>(SELECT AVG(amount) FROM bill);

You might also like