prac file (hy) sql
prac file (hy) sql
Practices Chapter-1
Querying and SQL Functions
d) SELECT YEAR(“1979/11/26”),
MONTH(“1979/11/26”), DAY(“1979/11/26”),
MONTHNAME(“1979/11/26”);
2);
>>UPDATE Product
SET Discount = UPrice * 0.10
WHERE UPrice > 100;
v.Increase the price by 12 per cent for
all the products manufactured by
Dove.
>>UPDATE Product
SET UPrice = UPrice * 1.12
WHERE Manufacturer =
'Dove';
PName;
Using the CARSHOWROOM database given in the chapter,
write the SQL queries for the following:
a) Add a new column Discount in the INVENTORY table.
>>ALTER TABLE INVENTORY
ADD Discount DECIMAL(5,2);
>>UPDATE INVENTORY
SET Discount = 0
WHERE Model = 'LXI';
>>UPDATE INVENTORY
SET Discount = 10
WHERE Model = 'VXI';
>>UPDATE INVENTORY
SET Discount = 12
WHERE Model NOT IN ('LXI', 'VXI');
c) Display the name of the costliest car with fuel type
“Petrol”.
>>SELECT CarId,
MAX(CarName) FROM
INVENTORY
WHERE FuelType = 'Petrol';
>>UPDATE
Student SET
StCode = 'S03'
WHERE Name = 'Jay';
e) Display the names of students whose names end
with the character ‘a’. Also, arrange the students in
alphabetical order.
>>SELECT Name
FROM Student
WHERE StCode IN ('S01', 'S03')
ORDER BY Name, AdmNo;
g) List the number of students in each stream
having more than 1 student.