0% found this document useful (0 votes)
7 views1 page

SQL Practice

The document outlines a series of SQL practice questions aimed at creating a database and performing various operations. It includes tasks such as creating tables for houses and students, setting primary and foreign keys, and executing SQL queries to retrieve specific data. The exercises cover data insertion and various retrieval operations based on different conditions and sorting requirements.

Uploaded by

raneerizal
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)
7 views1 page

SQL Practice

The document outlines a series of SQL practice questions aimed at creating a database and performing various operations. It includes tasks such as creating tables for houses and students, setting primary and foreign keys, and executing SQL queries to retrieve specific data. The exercises cover data insertion and various retrieval operations based on different conditions and sorting requirements.

Uploaded by

raneerizal
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/ 1

SQL practice questions

1. Create a database with the name of your own choice.


2. Create the following tables with appropriate data types.
a. Houses(house_id, abbreviation, house_name) and
b. Students(std_id, roll_no, name, house_id).
3. Set the appropriate primary keys and required foreign keys on the tables above.
4. Add some relevant data in those tables. Add at least 4 houses and 15 students.
5. Perform the following operations using SQL queries.
a. Retrieve all columns from the students table.
b. Retrieve the name and roll_no columns for all students.
c. Retrieve all columns from the house table.
d. Retrieve the name and house_name of all students and their respective house.
e. Retrieve the std_id, name, and house_name for students who belong to the "GH".
f. Retrieve the names of students who have a roll_no number greater than "50".
g. Retrieve the names of all students sorted by their name in ascending order.
h. Retrieve all students who are not assigned to any house (i.e., house_id is NULL).
i. Retrieve the house_name of all houses that have students assigned to them.
j. Retrieve the std_id and name of students whose name starts with the letter "A".
k. Retrieve all students who are in a house with house_id = 2.
l. Retrieve the total number of students in the students table.
m. Retrieve the distinct house names from the house table.
n. Retrieve the students who belong to either "RH" or "BH".
o. Retrieve all students and sort them by their roll_no in descending order.

You might also like