0% found this document useful (0 votes)
3 views4 pages

SQL Queries for Student, Employee, Hospital, and Doctor Data

The document contains SQL queries based on four tables: Student, Employee, Hospital, and Doctors. It includes queries for inserting data, displaying details, selecting specific columns, and filtering records based on conditions. Each section provides a set of questions followed by the corresponding SQL query answers.

Uploaded by

ajeesrotrix31
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)
3 views4 pages

SQL Queries for Student, Employee, Hospital, and Doctor Data

The document contains SQL queries based on four tables: Student, Employee, Hospital, and Doctors. It includes queries for inserting data, displaying details, selecting specific columns, and filtering records based on conditions. Each section provides a set of questions followed by the corresponding SQL query answers.

Uploaded by

ajeesrotrix31
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

[Link] write queries from the following questions based on the given table.

Table name: Student.


Roll no Name Gender Age Dept DOB
1 Arun M 22 Computer 2008-04-01
2 Geetha F 19 Science 2009-12-12
3 Madhu F 17 Hindi 2008-08-05
4 Raj M 20 Null 2007-06-16

1. Write a query to insert all the rows of the above table.

2. Write a query to display all the details of the students.

3. Write a query to display Name, Age, Dept.

4. Write a query to select distinct department from student table.

ANSWER:

[Link] into student values(1,”Arun”,”M”,17,”Computer”,” 2008-04-


01”);
Insert into student values(2,”Geetha”,”F”,16,”Science”,” 2009-12-
12”);
Insert into student values(3,”Madhu”,”F”,17,”Hindi”,” 2008-08-05”);
Insert into student values(4,”Raj”,”M”,18,null,” 2008-04-01”);
2. select * from student;
3. select name,age,dept from student;
4. select distinct(dept) from student;
2. To write queries from the following questions based on the given table.
Table name: Employee.
Emp Id Name Design Salary Allowance
1 Anand Manager 80000 5600
2 Anu Clerk 20000 1600
3 Usha Supervisor 49000 3600
4 Shakthi Clerk Null 2100

1. Write a query to create the table name Employee with column names as
given in the table.

2. Write a query to list the names of Employee’s whose salary is above


25000.

3. Write a query to display name of all employees whose salary is Null.

[Link] a query to delete the record of employees who have salary greater
than 40000.

ANSWER

[Link] employee(EmpId int,Name char(40),Design


char(50),Salary int, allowance int);
2. select name from employee where salary>25000;
[Link] name from employee where salary is null;
4. delete from employee where salary>40000;
[Link] write queries from the following questions based on the given table.
Table name: Hospital.
Pname Fee Gender Date of
visit
Rahul 200 M 2017-09-
05
Ramesh 300 M 2018-03-
02
Usha 350 F 2015-06-
09
Sunil 400 M 2012-01-
03

[Link] information of patients who visited after 2015-06-09.


[Link] the names of patients whose name starts with alphabet R.
[Link] the patients whose fee is above 300.
[Link] the patients whose names ends with ‘A’.

ANSWER:
1. Select *from hospital where dateofvisit>”2015-06-09”;
2. Select pname from hospital where pname like “R%”;
3. Select * from hospital where fee>300;
4. Select * from hospital
PatId PatName Departmen DocId
where pname like “%a”; t
1 Anand ENT 101
2 Anu Ortho 102
3 Usha Cardiology 103
4 Shakthi ENT 104
[Link] write queries from the following
questions based on the given table.
Table name: Doctors.
Table name: Patients
DocId DocName Fees

101 Smitha 1500


102 Gupta 1000

103 Sharma 1500

104 Nithya 2500

[Link] DocName, Fees of doctors above 2000.

[Link] the list of all patients whose department is ENT.


3. Display the PatId, PatName and corresponding DocName for each patient.
[Link] the details of all doctor’s name in descending order.

ANSWER:
1. Select docname,fees from doctors where fees>2000;
2. Select * from patients where department=”ENT”;
3. Select patid,patname,docname from doctors, patients where
[Link]=[Link];
4. Select * from doctors order by docname desc;

You might also like