Questions For SQL and Query: Answers
Questions For SQL and Query: Answers
Answers:-
A) CREATE TABLE Icecream (VendorID numeric primary key, VName varchar (50),
Cart_Cost numeric, Location Varchar (70));
B) Insert into Icecream values(V005,’Vadilal’,700,’Pune’);
C) Select * from Icecream where Cart_Cost>1500;
D) Alter table Icecream add date_of_delivery date;
Note: (for answer D) in this we are adding a new field that’s why we are using alter table
but if we want to add new record we will use insert
Degree:- no. of columns
Cardinality :- no. of rows
Answers:-
a) DEPTID is the suitable field for Primary Key. It is the unique field for each
department.
b) Command/queries:-
i) Create table ADMIn (DEPTID numeric primary key, DEPTNAME
varchar (40), EMPLOYEE_NAME varchar(50), CITY varchar (50));
ii) Select * from ADMIN where DEPTNAME=’HR’;
iii) Update ADMIN set CITY=’Jaipur’ where DEPTID+’DEP104’;
(NOTE:- we use update because we are updating the existing
record)
iv) Select * from ADMIN order by EMPLOYEE_NAME asc; (NOTE:- we
use order by because we want our record in ascending order)
Answer:-
a) Select AVG (MRP) from FURNITURE where MATERIAL=’wood’; (AVG is
using here for average)
b) Select FURNITURE_CODE, DISCOUNT_PERCENT from FURNITURE where
MRP>20000;
c) Update FURNITURE set DESCRIPTION=’bed’, MATERIAL=’fibre’ where
FURNITURE_CODE=’F002’;
d) Select * from FUIRNITURE where DESCRIPTION like ‘%e’;