0% found this document useful (0 votes)
69 views15 pages

SQL Practice & Exercise: MIS 305, Section: 01, 02 & 03 Instructor: Rezwanul Alam

This document provides SQL exercises to practice selecting data from single and multiple tables with and without conditions. The exercises demonstrate basic SQL commands like SELECT, FROM, WHERE, and joining multiple tables. Some key examples include selecting student names and details from a single table, filtering rows based on conditions, and joining data from related tables based on common columns.

Uploaded by

Musa Shahrier
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views15 pages

SQL Practice & Exercise: MIS 305, Section: 01, 02 & 03 Instructor: Rezwanul Alam

This document provides SQL exercises to practice selecting data from single and multiple tables with and without conditions. The exercises demonstrate basic SQL commands like SELECT, FROM, WHERE, and joining multiple tables. Some key examples include selecting student names and details from a single table, filtering rows based on conditions, and joining data from related tables based on common columns.

Uploaded by

Musa Shahrier
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 15

SQL Practice & Exercise

MIS 305, Section: 01, 02 & 03 Instructor: Rezwanul Alam

SQL
SELECT
List the columns from tables that the user would like to see in a result table

FROM
Identifies the tables or views from which columns will be selected

WHERE
Includes conditions for selecting specific rows (records) within a single table and conditions for joining multiple tables

Exercise Single Table without Condition


1. List the Student IDs, Names of the Students SELECT ID, Name FROM Student;

ID

Name

1017 Anwar
1045 Zinia 1118 Simi 1120 John

1160 Mehedi
1224 Mamun 1290 Asif

Exercise Single Table without Condition


2. List Name, ID, Department of Students SELECT Name, ID, Department FROM Student;
Name Anwar Zinia Simi ID Department 1017 English 1045 BBA 1118 Computer Science

John
Mehedi Mamun Asif

1120 BBA
1160 BBA 1224 BBA 1290 Computer Science

Exercise Condition use of WHERE


Expression = Meaning Equal

<>
< > <= >= AND

Not equal
Less than Greater than Less than or Equal Greater than or Equal AND

OR

OR

Exercise Single Table with Condition


3. List ID, Name & Department of Students who took 3 or more courses SELECT ID, Name, Department FROM Student WHERE Total_Courses >= 3;
ID Name Department
BBA BBA BBA 1045 Zinia 1160 Mehedi 1224 Mamun

1118 Simi
1120 John

Computer Science
BBA

Exercise Single Table with Condition


4. List the Name of Students who DO NOT live in Banani SELECT Name
Name

FROM Student WHERE Address_Zone <> Banani;

Mehedi
Anwar Simi Asif

John

Exercise Joining Tables without Condition


5. List Name, Department & Department_Head of all students. SELECT Student.Name, Student.Department, Office.Department_Head FROM Student, Office WHERE Student.Department = Office.Department;

Exercise Joining Tables without Condition


5. List Name, Department & Department_Head of all students.
Name John Mamun Mehedi Zinia Asif Simi Anwar Department BBA BBA BBA BBA Computer Science Computer Science English Department_Head Dr. Lisa Dr. Lisa Dr. Lisa Dr. Lisa Dr. Zaman Dr. Zaman Dr. Alex

Exercise Joining Tables with Condition


6. List Name, Department & Department_Head of all students who live in Mohakhali SELECT Student.Name, Student.Department, Office.Department_Head FROM Student, Office WHERE Student.Department = Office.Department

AND Student.Address_Zone = Mohakhali;

Exercise Joining Tables with Condition


6. List Name, Department & Department_Head of all students who live in Mohakhali

Name Anwar John

Department English BBA

Department_Head Dr. Alex Dr. Lisa

Exercise Joining 3 Tables without Condition


7. List Name, Department_Head & Probation_Status of all Students SELECT Student.Name, Office.Department_Head, Registration.Probation_Status FROM Student, Office, Registration WHERE Student.Department = Office.Department

AND Student.ID = Registration.Student_ID;

Exercise Joining 3 Tables without Condition


7. List Name, Department_Head & Probation_Status of all Students
Name Department_Head Probation_Status

John
Mamun Mehedi Zinia

Dr. Lisa
Dr. Lisa Dr. Lisa Dr. Lisa

NO
YES NO NO

Asif
Simi Anwar

Dr. Zaman
Dr. Zaman Dr. Alex

NO
NO YES

Exercise Joining 3 Tables with Condition


8. List Name, Office_Location, Payment_Status of all Students who have already PAID SELECT Student.Name, Office.Office_Location, Registration.Payment_Status FROM Student, Office, Registration WHERE Student.Department = Office.Department

AND Student.ID = Registration.Student_ID


AND Registration.Payment_Status = Paid;

Exercise Joining 3 Tables with Condition


8. List Name, Office_Location, Payment_Status of all Students who have already PAID
Name Mamun Mehedi John Zinia Anwar Office_Location DDC Building DDC Building DDC Building DDC Building Payment_Status PAID PAID PAID PAID

Research Building PAID

You might also like