Beruflich Dokumente
Kultur Dokumente
address) for the people who are staying more then 10 days.
FROM room_allocation
+-------+--------------+------------+------+
+-------+--------------+------------+------+
+-------+--------------+------------+------+
>>>>>>>>>>>>>>>FINAL:
FROM patient_master
FROM room_allocation
+-------+--------+------------+
+-------+--------+------------+
__________________________________________________________________________________
____________________________
end as 'type_of_ailment'
WHERE p.pid=r.pid;
+-------+--------+------+------------------+-----------------+
+-------+--------+------+------------------+-----------------+
+-------+--------+------+------------------+-----------------+
3) Display the doctor_id and doctor name who is treating maximum patients.
WHERE p.doctorid=d.doctorid
GROUP BY doctorid;
+----------+------------+--------------+
+----------+------------+--------------+
| D0003 | Smita | 1|
| D0004 | Bhavan | 1|
| D0005 | Netra | 1|
+----------+------------+--------------+
FROM(
WHERE p.doctorid=d.doctorid
GROUP BY doctorid
FROM patient_master
GROUP BY pid)a
)s;
+----------+------------+
| doctorid | doctorname |
+----------+------------+
| D0003 | Smita |
| D0004 | Bhavan |
| D0005 | Netra |
+----------+------------+
+---------+-------+------------+--------------+
+---------+-------+------------+--------------+
+---------+-------+------------+--------------+
FROM patient_master
+-------+------+-----+--------+--------+---------+------------+---------------+----------+
+-------+------+-----+--------+--------+---------+------------+---------------+----------+
+-------+------+-----+--------+--------+---------+------------+---------------+----------+
5) Display the patient_id and patient_name who paid more then once.
+--------+-------+---------+
+--------+-------+---------+
+--------+-------+---------+
FROM patient_master
WHERE pid in (SELECT pid FROM bill_payment GROUP BY pid HAVING count(pid)>1);
6) Display the doctor_id, doctor_name and count of patients. Display the data in descending order of
the cont_of_patients.
WHERE d.doctorid=p.doctorid
GROUP BY d.doctorid
+----------+------------+------------------+
| D0004 | Bhavan | 1|
| D0005 | Netra | 1|
| D0003 | Smita | 1|
+----------+------------+------------------+
7) Display the room_no, room_type which are allocated more then once.
+---------+-------+------------+--------------+
+---------+-------+------------+--------------+
+---------+-------+------------+--------------+
FROM room_master
| room_no | room_type |
+---------+-----------+
| R0002 | Suite |
+---------+-----------+
8) Display the room_no, room_type which are allocated more then once to the same patient.
+---------+-------+------------+--------------+
+---------+-------+------------+--------------+
+---------+-------+------------+--------------+
FROM room_master
WHERE room_no IN (SELECT room_no FROM room_allocation GROUP BY pid HAVING count(pid)>1);
__________________________________________________________________________________
____________________________
d.doctorid, d.doctorname,
rm.room_no, rm.room_type,
ra.adm_date,
+-------+--------+----------+------------+---------+-----------+------------+--------+--------+
+-------+--------+----------+------------+---------+-----------+------------+--------+--------+
+-------+--------+----------+------------+---------+-----------+------------+--------+--------+
10) Display the patient_id, patient_name, billid, amount. Amount should be rounded of to single
place of decimal.
WHERE p.pid=b.pid;
+-------+--------+--------+-------------------+
+-------+--------+--------+-------------------+
| P0001 | Gita | B0001 | 1200.6 |
+-------+--------+--------+-------------------+
__________________________________________________________________________________
____________________________
11) Display the room_no which was never allocated to any patient.
+---------+-------+------------+--------------+
+---------+-------+------------+--------------+
+---------+-------+------------+--------------+
SELECT room_no
FROM room_allocation
GROUP by room_no
HAVING count(room_no)>1;
+---------+
| room_no |
+---------+
| R0002 |
+---------+
12) Display the the doctors_id who never treated any patients.
SELECT doctorid
FROM doctor_master
+----------+
| doctorid |
+----------+
| D0001 |
| D0002 |
| D0006 |
+----------+
13) The depatment which are having the maximum number of doctors.
FROM doctor_master
GROUP BY dept;
+---------+-----------------+
| dept | count(doctorid) |
+---------+-----------------+
| ENT | 2|
| Eye | 1|
| Surgery | 3|
+---------+-----------------+
FROM doctor_master
GROUP BY dept;
SELECT dept
FROM doctor_master
GROUP BY dept
FROM doctor_master
GROUP BY dept)a
);
+---------+
| dept |
+---------+
| Surgery |
+---------+
FROM patient_master
GROUP BY gender;
+--------+------------+
| gender | count(pid) |
+--------+------------+
|F | 2|
|M | 1|
+--------+------------+
OR
SELECT m.mc as MALES, f.fc as FEMALES
FROM
+-------+---------+
| MALES | FEMALES |
+-------+---------+
| 1| 2|
+-------+---------+
__________________________________________________________________________________
____________________________
+-------+---------+
| MALES | FEMALES |
+-------+---------+
| 33% | 67% |
+-------+---------+