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

SQL Select Query

The document outlines SQL commands for creating and manipulating a HOSPITAL table, including creating the table with specific fields and constraints, inserting records, modifying the table structure, and querying patient information based on various criteria. It also includes questions related to databases, data models, table components, and keys in RDBMS. The document serves as a guide for performing database operations and understanding fundamental database concepts.

Uploaded by

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

SQL Select Query

The document outlines SQL commands for creating and manipulating a HOSPITAL table, including creating the table with specific fields and constraints, inserting records, modifying the table structure, and querying patient information based on various criteria. It also includes questions related to databases, data models, table components, and keys in RDBMS. The document serves as a guide for performing database operations and understanding fundamental database concepts.

Uploaded by

pankajranga559
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

Write the SQL command to create the following table HOSPITAL


Field Name Data Type Constraints
Pno Number Primary Key
Name Varchar2(20) Unique
Age Number(2) Check>18
Dept Char(3) Default=”OPD”
DOA Date
Charges Number(7,2) Check>100
Gender Char(1)

2. Insert one record in above table.


3. Add one more column in the above table as Address of type varchar2(20)
4. Delete all the rows of the table.
5. List the names of female patients who are in ENT department.
6. List patient’s name, charges, age of male patients only.
7. List the name and charges where charges are above 500.
8. Show all details of patients who belongs to either ENT,OPD,ORT department.
9. Find the name of all the patients who have not given charges.
10. List the different departments available in hospital.
11. Show all the information of those patients whose DOA is above 1st January 2008.
12. Show increased charges by 10% of all patients who are in ENT dept.
13. Show all details of female patients who are in NUC dept
14. Show name and age of those patients who are more than 50 years old, male and
admitted in 1998/
15. Show details of Kush.
Answer the following queries on the basis of table given below (HOSPITAL):
Pno Name Age Dept DOA Charges Gender
1 Arpit 62 SUR 21-Jan-98 300 M
2 Zarina 22 ENT 12-Dec-97 250 F
3 Kareem 32 ORT 19-Feb-98 200 M
4 Arun 12 SUR 11-Jan-98 600 M
5 Zubin 30 ENT 12-Jan-98 250 F
6 Ankita 20 CAR 20-Feb-98 260 F
7 Kush 55 NUC 13-Jan-98 800 M
8 Shilpa 23 GYN 22-Oct-99 700 F
1. Select name, age from hospital where charges>300;
2. Select * from hospital where pno=5;
3. Select name, dept from hospital where charges in (250,700) and gender=’M’;
4. Select charges from hospital where dept=’ENT’ or Age<30;
5. Select distinct dept from hospital;

Learn the following questions:


Q) What is database? What is its significance?

Q)Define different Data Models?

Q) What are the different components of a Table / Relation?

Q)What do you mean by Key? Define different keys in RDBMS?

You might also like