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

SQL Questions Practical File

Contains SQl questions

Uploaded by

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

SQL Questions Practical File

Contains SQl questions

Uploaded by

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

Q) Consider the following table named “Product”, showing details of products

being sold in a grocery shop.

Write SQL queries for the following:


a) Create the table Product with appropriate data types and constraints.
b) Identify the primary key in Product.
c) List the Product Code, Product name and price in descending order of their
product name. If PName is the same, then display the data in ascending order of
price.
d) Add a new column Discount to the table Product.
e) Calculate the value of the discount in the table Product as 10 per cent of the
UPrice for all those products where the UPrice is more than 100, otherwise the
discount will be 0.
f) Increase the price by 12 per cent for all the products manufactured by Dove.
g) Display the total number of products manufactured by each manufacturer.
Write the output(s) produced by executing the following queries on the basis of
the information given above in the table Product:
h) SELECT PName, avg(UPrice) FROM Product GROUP BY Pname;
i) SELECT DISTINCT Manufacturer FROM Product;
j) SELECT COUNT (DISTINCT PName) FROM Product; k) SELECT PName,
MAX(UPrice), MIN(UPrice) FROM Product GROUP BY PName;
CREATING TABLE
use product;
create table Product2
(PCode varchar(3) primary key,
PName varchar(20),
UPrice int,
Manufacturer varchar(20)
);

INSERTING VALUES
insert into Product2 values ('P01','Washing Powder',120,'Surf');
insert into Product2 values ('P02','Toothpaste',54,'Colgate');
insert into Product2 values ('P03','Soap',25,'Lux');
insert into Product2 values ('P04','Toothpaste',65,'Pepsodent');
insert into Product2 values ('P05','Soap',38,'Dove');
insert into Product2 values ('P06','Shampoo',245,'Dove');
OUTPUT:-

You might also like