Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
140 views3 pages

Questions of SQL Assignment

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 3

National University of Computer & Emerging Sciences, Karachi

FALL 2022

Assignment

Course Code: CL-1000 Course Name: Intro to Info & Comm. Technologies
Instructor Name: Tooba Qazi Total Marks : 10

Q1. What is the main difference between Primary Key, Unique Key, and Foreign Key?

Q2. What is the purpose of a JOIN statement? Also, explain the different types of JOIN
clauses supported in SQL.

Q3. What are the main points that differentiate between the “delete”, “truncate” and “drop”
commands?

Q4. SQL Script and Query

Sample Table – Worker

WORKER_ID FIRST_NAME LAST_NAME SALARY JOINING_DATE DEPARTMENT

001 Monika Arora 100000 2014-02-20 09:00:00 HR

002 Niharika Verma 80000 2014-06-11 09:00:00 Admin

003 Vishal Singhal 300000 2014-02-20 09:00:00 HR

004 Amitabh Singh 500000 2014-02-20 09:00:00 Admin

005 Vivek Bhati 500000 2014-06-11 09:00:00 Admin

006 Vipul Diwan 200000 2014-06-11 09:00:00 Account

007 Satish Kumar 75000 2014-01-20 09:00:00 Account

008 Geetika Chauhan 90000 2014-04-11 09:00:00 Admin


Sample Table – Bonus

WORKER_REF_ID BONUS_DATE BONUS_AMOUNT

1 2016-02-20 00:00:00 5000

2 2016-06-11 00:00:00 3000

3 2016-02-20 00:00:00 4000

1 2016-02-20 00:00:00 4500

2 2016-06-11 00:00:00 3500

Sample Table – Title

WORKER_REF_ID WORKER_TITLE AFFECTED_FROM

1 Manager 2016-02-20 00:00:00

2 Executive 2016-06-11 00:00:00

8 Executive 2016-06-11 00:00:00

5 Manager 2016-06-11 00:00:00

4 Asst. Manager 2016-06-11 00:00:00

7 Executive 2016-06-11 00:00:00

6 Lead 2016-06-11 00:00:00

3 Lead 2016-06-11 00:00:00

1. Create table for workers, Titles and Bonus, don’t forget to mention data type. Sample is
attached.
2. Insert same values in all three tables as above.
3. Write an SQL query to fetch “FIRST_NAME” from Worker table using the alias name as
<WORKER_NAME>.

4. Write an SQL query to fetch “FIRST_NAME” from Worker table in upper case.

5. Write an SQL query to fetch unique values of DEPARTMENT from Worker table.

6. Write an SQL query to print all Worker details from the Worker table order by
FIRST_NAME Ascending.

7. Write an SQL query to print all Worker details from the Worker table order by
FIRST_NAME Ascending and DEPARTMENT Descending.

8. Write an SQL query to print details for Workers with the first name as “Vipul” from
Worker table.

9. Write an SQL query to print details of the Workers whose FIRST_NAME contains ‘s’.

10. Write an SQL query to print details of the Workers whose FIRST_NAME ends with ‘a’.

11. Write an SQL query to fetch the count of employees working in the department ‘Admin’.

12. Write an SQL query to print details of the Workers whose SALARY greater than 100000.

You might also like