0% found this document useful (0 votes)
56 views35 pages

Sneha Singh 01650501719 Ism Lab File

The document outlines 20 assignments related to SQL queries. The assignments cover skills like creating tables, inserting data, selecting records, updating records, adding and dropping columns, and aggregate functions.

Uploaded by

singhsneha83832
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)
56 views35 pages

Sneha Singh 01650501719 Ism Lab File

The document outlines 20 assignments related to SQL queries. The assignments cover skills like creating tables, inserting data, selecting records, updating records, adding and dropping columns, and aggregate functions.

Uploaded by

singhsneha83832
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
You are on page 1/ 35

BANARSIDAS CHANDIWALA INSTITUTE OF PROFESSIONAL

STUDIES

Affiliated to Guru Gobind Singh Indraprastha University, New Delhi

INFORMATION SYSTEM MANAGEMENT LAB BBA-212

BBA 2019-22

Submitted to: Submitted by:


Ms. Pooja Yadav Sneha Singh
Assistant Professor 01650501719
BBA IV Sem SS
S. No Assignment

1 Assignment 1
- To write SQL queries to create table and insert data

2 Assignment 2
- To write SQL queries using select command

3 Assignment 3
- To write SQL queries using aggregate functions

4 Assignment 4
- To create a table with constraints

5 Assignment 5
- To write SQL queries for select and update command

6 Assignment 6
- To write SQL queries with alter command

7 Assignment 7
- To write SQL queries on Create table command
- Insert command
- Select command
- Modify command
- Delete command
- Using different mathematical functions
8 Assignment 8
- To write SQL queries on Create table command
- Insert command
- Select command
- Modify command
- Delete command
- Using different mathematical functions

SQL
Assignment 1
a. Write an SQL command that will create a table named Test1 with the following fields
and types: idno NUMERIC(10) , fname VARCHAR(24), address VARCHAR(30),
age NUMERIC(10) , giftvalue NUMERIC(10,2).

b. Insert the following items in the table you have created

ENo FirstName Address1 Age Gift

01 Ram Dwarka sector 41 200


10

02 Sita Janakpuri 26 250


block C

03 Rajesh Dwarka sector 23 200


15

04 Ajit Noida sector 35 150


11

05 Rita Noida sector 40 200


11

Assignment 2: Select Queries for table Test1

a. Write an SQL query to display all the records


b. Write an SQL query to display all the records where age >40
c. Write an SQL query to display Fname, Age from the table
d. Write an SQL query to display Fname, Age, Gift where Age > 35 from the
table

e. Write an SQL query to display all record where Gift > 200 and Age >20
f. Write an SQL query to display all record where Gift > 200 or Age >20

Assignment 3: Queries for aggregate functions for table Test1


a. Write SQL query to add the age of all records.

b. Write a query to average of the cost of gifts.

c. Write a query to display the name and age of the youngest member
d. Write a query to count the number of candidates whose age in more than 30.

e. Write a query to find the name and cost of the costliest gift.
Assignment 4: Constraints

a. Create a table “Employee” with the following specifications

Field name Data type

EMPID INT, Primary Key

DEPT VARCHAR(5)

EMPNAME CHAR(15), Not Null

ADDRESS VARCHAR(30)

SALARY NUMERIC(7), Salary>=7000


b. Make the following entries in the table

EMPID DEPT EMPNAME ADDRESS SALARY

101 RD01 Prince Park Way 15000

102 RD01 Harry Pebble Street 12000

103 RD02 Tom Rose Garden 11000

104 RD02 Susan Model Town 10000

105 ED01 Mark Victor Crescent 10000

106 AD01 Francis Chelmsford 13000


Park

107 GR01 Robert Downtown 14000


Cross

108 RD03 Philip Park Avenue 15000

109 RD03 Henry Malibu Beach 14000

110 AD01 Frank St. Peters Lane 7000


Assignment 5: Select & Update
a. Find names for all employees who work for the RD01 department.

b. How many employees work in department starting from RD.


c. What is the maximum and minimum of the salaries.

d. Name the employees and their department whose salaries are greater than 12000.
e. Find the number of employees in each department.

f. List the employees in increasing order of their salaries.


g. Modify the table so that Susan is assigned to AD01 department.

h. Change the salary of all the employees to AD01 to salary*1.2


i. Name the employee in department RD03 who lives in Park Avenue.

j. Find the Average salary.


k. Count the number of employees.
Assignment 6: Alter
Create a table Student1 with the following structure:
Roll no number 3
Name varchar 20
Marks number 6

Write the following SQL queries


1. Add new columns pincode and city to Student1
2. Change the width of pincode to 6

Alter table student1


Modify column pincode numeric(6)

3. Add a new column with primary key constraints

Alter table student1 add primary key (rollno)

4. Add a new column with not null constraint

Alter table student1 modify name int not null

5. Add construct check to the Marks column (Marks >=0 and Marks<=100)
Alter table student1 add check (marks>=0 and marks <= 100)
Assignment 7
Write SQL queries for the following:
a. To create a table Client_Details with the following specifications.

Column Data Type Size Attributes


Name
Client_No Char 6 Primary Key
Name Varchar 30 Not Null
City Varchar 20
State Varchar 20
Pin_Code Numeric 6
Bal_due Numeric 10,
2

b. To insert the following data into the table

Client_N Name City StatePin_Cod Bal_due


o e
C00001 Ramesh Kumar Mumbai Maharashtra 400054 15000
C00002 Vandana Saitwal Madras Tamil Nadu 780001 0
C00003 Pramada Jaiswal Mumbai Maharashtra 400057 5000
C00004 Rukmini Delhi Delhi 100001 2000

c. To display the names of all the clients

d. To display the maximum balance due under the heading “Max Bal_due”
e. To change the pin code of client no C00001 to 400058.
f. To display the details of clients in increasing order of their balance due.

g. To display the Name and Bal_due of clients who live in Mumbai and their
Bal_due<10000.
Assignment 8
1. Write an SQL command that will create a table named Friend with the following fields
and types: idno NUMERIC(10) PRIMARY KEY, fname VARCHAR(24), address
VARCHAR(30), age INT NOT NULL, giftvalue NUMERIC(10,2).

2. insert the following items in the table you have created

Idno FName Address Age Giftvalue


01 Ram Dwarka sector 10 41 200
02 Sita Janakpuri block c 26 250
03 Rajesh Dwarka sector 15 23 200
04 Ajit Noida sector 11 35 150
05 Rita Noida sector 11 40 200
3. Write an SQL command to add a new record in the Friend table with details of your
choice.
4. Write an SQL query to display all the records whose name starts with R.

5. Write an SQL query that will insert a complete record into the Friend table with these
values for the respective fields: '123', 'Tasmanian Devil', 'Tasmania', 23, 29.99.
6. Write an SQL query to insert a record with idno as 21, name as urvashi, address as
delhi.

7. Write an SQL query to change the age of Sita to 28.


8. Write an SQL query to delete the record of idno 123.

9. Write an SQL query that will update the giftvalue to 49.99 for all people in the Friend
table who are 31 and older.
10. Write an SQL query that will add a new field/column ‘City’ to the Friend table. You
can choose its type and size.

11. Write an SQL query to delete the field ‘City’ that you added in the Friend table.
alter table friend
drop city
12. Write an SQL query to insert a record with name Ram and other details of your
choice.
13. Write an SQL query to display fname and age of all the records.

14. Write SQL query to add the age of all records.

15. Write a query to average of the cost of gifts.


16. Write a query to display the name and age of the youngest member

17. Write a query to count the number of candidates whose age in more than 30 years.
18. write a query to find the name and cost of the costliest gift.

19. Write an SQL query that will delete all records from the Friend table where the
giftvalue is over 100.
20. Write a query to delete all the records.

You might also like