Home Work-2 Function in MySQL (Answers) 13 Apr 2020
Home Work-2 Function in MySQL (Answers) 13 Apr 2020
I. Display Item name, unit price along with Total amount (i.e. price*qty) for
all the Items.
Ans. Select itemname, unitprice, unitprice*quantity as “Total amount”
from grocer;
II. Display Item name along with Month (in number) when it was purchased
for all the items.
Ans. Select itemname, month(date_purchase) from grocer;
III. Display Item name along with year in which it was purchased for all the
items.
Ans. Select itemname, year(date_purchase) from grocer;
IV. Display Item Id, Date of Purchase and day name of week (e.g. Monday)
on which it was purchased for all the items.
Ans. Select item_id, date_purchase, dayname(date_purchase) from
grocer;
VI. Display the day name of the week on which Rice was purchased.
Ans. Select dayname(date_purchase) from grocer where
temname=”Rice”;
VII. Display the Item name and unit price rounded to integer value (no
decimal digits) of all the items.
Ans. Select itemname, round(unitprice, 0) from grocer;