Question:medium

Write suitable SQL query for the following:

I. To display the value of 172.

II. To display the day part of the dates in the Hire_Date column of the Employee table.

III. To display the maximum value of the Bill_Amount column in the Bill table.

IV. To remove leading and trailing spaces from the Location column in the Branch table.

V. To display total salary from tot_sal column in Employees table.

Show Hint

Use POW() for the power, DAY() for the day part, MAX() for the largest value, TRIM() to remove spaces and SUM() for the total.
Updated On: Oct 20, 2026
Show Solution

Solution and Explanation

Step 1: Match each task to a function:
We read the five tasks one by one and pick the MySQL function whose job matches the task. Then we write a SELECT query around it.
- Raising a number to a power needs POWER (or POW).
- Taking the day out of a date needs DAY.
- Finding the biggest value in a column needs MAX.
- Cutting spaces from both ends needs TRIM.
- Adding all values of a column needs SUM.

Step 2: Task I - the value of $17^2$:
This task has no table, so the query has no FROM clause. We pass 17 and then 2 to POWER.
SELECT POWER(17, 2);

MySQL calculates $17 \times 17$ and shows 289.

Step 3: Task II - day of Hire_Date:
Hire_Date holds a full date. DAY gives only the day number for each row. The data comes from the Employee table, so FROM Employee is needed.
SELECT DAY(Hire_Date) FROM Employee;

An employee hired on 2023-11-07 shows 7.

Step 4: Task III - largest Bill_Amount:
MAX is an aggregate function. It reads the whole column and gives back one row with the biggest value.
SELECT MAX(Bill_Amount) FROM Bill;


Step 5: Task IV - trim the Location column:
TRIM removes the blank spaces before the first letter and after the last letter. The data lives in the Branch table.
SELECT TRIM(Location) FROM Branch;

The text ' Pune ' becomes 'Pune'.

Step 6: Task V - total of tot_sal:
SUM is the aggregate function for a total. It gives one number for the whole column of the Employees table.
SELECT SUM(tot_sal) FROM Employees;


Final Answer:
I. SELECT POWER(17, 2); gives 289.
II. SELECT DAY(Hire_Date) FROM Employee;
III. SELECT MAX(Bill_Amount) FROM Bill;
IV. SELECT TRIM(Location) FROM Branch;
V. SELECT SUM(tot_sal) FROM Employees;
Was this answer helpful?
0