Think about your own organization or an imaginary one and de

Think about your own organization or an imaginary one and describe a query that you might use that would need a subquery and a calculated field. Be sure to describe the business as well. Show a sample of what the query might look like.

Solution

So, I work in a company and we have a system to check in and check out from office. We have to ensure that we spent 8 hours in office. Lets suppose we have two tables

info table

in_out_time table

Suppose we want to find all the employee name who spend less than 8 hour in a particular date and their salary increment, which will be a calculated field

We have to use a subquery and a calculated field to get the result. The query will be something like this

SELECT name, department, (current_salary - start_salary) as salary_increment
FROM info
WHERE EmployeeID IN
(
SELECT EmployeeID
WHERE date = \'16012016\' AND check_out_time - check_in_time >= 8
FROM in_out_time
)
;

EmployeeID name department current_salary start_salary
Think about your own organization or an imaginary one and describe a query that you might use that would need a subquery and a calculated field. Be sure to desc

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site