Computer Science
Write Query statements for following transaction : (Consider tables of question 12)
- Increase price of all products by 10%.
- List the details of all orders whose payment is pending as per increased price.
- Decrease prices by 10% for all those products for which orders were placed 10 months before.
DDL & DML
4 Likes
Answer
The following tables are considered :
Orders (OrdNo, Ord_date, ProdNo#, Qty)
Product (ProdNo, Descp, Price)
Payment (OrdNo, Pment)
1.
UPDATE product
SET price = (price * 0.1) + price ;
2.
SELECT *
FROM Orders
JOIN Payment ON Orders.OrdNo = Payment.OrdNo
WHERE Payment.Pment = 'Pending';
3.
UPDATE Product
SET Price = Price - (Price * 0.1)
WHERE ProdNo IN (
SELECT ProdNo#
FROM Orders
WHERE YEAR(Ord_date) = YEAR(CURDATE()) - 1
AND MONTH(Ord_date) = MONTH(CURDATE()) - 10
);
Answered By
4 Likes
Related Questions
Given the following tables :
Orders (OrdNo, Ord_date, ProdNo#, Qty) Product (ProdNo, Descp, Price) Payment (OrdNo, Pment)
Write a query to delete all those records from table Orders whose complete payment has been made.
Enlist the names of all tables created by you.
Modify table Empl, add another column called Grade of VARCHAR type, size 1 into it.
In the added column Grade, assign grades as follows :
if sal is in range 700 — 1500, Grade is 1 ;
if sal is in range 1500 — 2200, Grade is 2 ;
if sal is in range 2200 — 3000, Grade is 3 ;
if sal is in range 3000 — Grade is 4 ;