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

SQL Practise Test

The document outlines a SQL practice test consisting of 28 questions aimed at testing various SQL skills. It includes tasks such as creating tables, inserting records, retrieving data, applying filters, and performing calculations. The questions cover a range of SQL concepts including foreign keys, views, constraints, and stored procedures.

Uploaded by

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

SQL Practise Test

The document outlines a SQL practice test consisting of 28 questions aimed at testing various SQL skills. It includes tasks such as creating tables, inserting records, retrieving data, applying filters, and performing calculations. The questions cover a range of SQL concepts including foreign keys, views, constraints, and stored procedures.

Uploaded by

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

SQL Practise Test

Q.1 Create Products table with column product_id PRIMARY KEY, product_name ,
category , unit_price
Q.2 Insert 5 records
Q.3 Create Sales table with column sale_id with PRIMARY KEY, product_id , quantity_sold
sale_date , total_price
Q.4 Apply foreign key on product_id in sales table
Q.5 Insert 5 records

Q.6. Retrieve the product_name and unit_price from the Products table.

Q.7 Filter the Sales table to show only sales with a total_price greater than $100.

Q.8 Filter the Products table to show only products in the 'Electronics' category.

Q.9 Calculate the total revenue generated from all sales in the Sales table.

Q.10 Count Sales Per Day from the Sales table

Q.11 Retrieve the total_price of all sales, rounding the values to two decimal places.

Q.12 Retrieve the sale_id and sale_date from the Sales table, formatting the sale_date as 'YYYY-MM-
DD'.

Q.13 Calculate the total revenue generated from sales of products in the 'Electronics' category.

Q.14 Retrieve the product_name and unit_price from the Products table, filtering the unit_price to
show only values between $20 and $600.

Q.15 Retrieve the product_name and total_price from the Sales table, calculating the total_price as
quantity_sold multiplied by unit_price

Q.16 Identify the Most Frequently Sold Product from Sales table

Q.17 Find the Products Not Sold from Products table

A.18 Count the number of sales made in each month.

Q.19 List all sales along with the corresponding product names.

Q.20 Categorize sales as "High", "Medium", or "Low" based on total price (e.g., > $200 is High, $100-
$200 is Medium, < $100 is Low).

Q.21 Identify sales where the quantity sold is greater than the average quantity sold.

Q.22 Calculate the number of days between the current date and the sale date for each sale.

Q.23 Write a query to create a view named Total_Sales that displays the total sales amount for each
product along with their names and categories.
Q.24 Retrieve the product details (name, category, unit price) for products that have a quantity sold
greater than the average quantity sold across all products.

Q.25 Create an index on the sale_date column and display info using sale_date

Q.26 Write a query to find all sales where the total price is greater than the average total price of all
sales.

Q.27 Add a check constraint to the quantity_sold column in the Sales table to ensure that the
quantity sold is always greater than zero.

Q.28 Develop a stored procedure named Update_Unit_Price that updates the unit price of a product
in the Products table based on the provided product_id.

You might also like