Consider following schema and write SQL for given statements.worker (id,firstname,lastname,salary,joining_date,dept)bonus(id,bonus_date,amount)1. Find firstname and lastname of worker whose amount is greater than 2400.2. List out salary of worker with id who got bonus
Question
Consider following schema and write SQL for given statements.worker (id,firstname,lastname,salary,joining_date,dept)bonus(id,bonus_date,amount)1. Find firstname and lastname of worker whose amount is greater than 2400.2. List out salary of worker with id who got bonus
Solution
- To find the firstname and lastname of workers whose bonus amount is greater than 2400, you would need to join the 'worker' and 'bonus' tables on the 'id' field and then filter for those records where 'amount' is greater than 2400. Here is the SQL for this:
SELECT w.firstname, w.lastname
FROM worker w
JOIN bonus b ON w.id = b.id
WHERE b.amount > 2400;
- To list out the salary of workers who got a bonus, you would again need to join the 'worker' and 'bonus' tables on the 'id' field. This time, you don't need to filter the records any further. Here is the SQL for this:
SELECT w.id, w.salary
FROM worker w
JOIN bonus b ON w.id = b.id;
Similar Questions
Consider following schema and write SQL for given statements.title (id,designation,DOJ), bonus(id,bonus_date,amount)Create tables with Primary Key, foreign key constraints in given schemas.1)Retrieve the employees who haven't received any bonuses.2)Retrieve the total bonus amount received by each employee.3)Retrieve the highest bonus amount received.4)List out id's whose bonus amount is at most 4000 and designation is admin
Consider following schema and write SQL for given statements.title (id,designation,DOJ)bonus(id,bonus_date,amount)1. List out bonus id whose designation is MANAGER .2. List out id's whose bonus amount at most 4000 and designation is admin
Write a query to display the ename of employees working in 'HR' department and who draw an annual salary greater than 1000000. [Consider employees who work in multiple departments too]. Display the records sorted in ascending order based on employee ename.Note:1. Display all the ename of employees working in 'HR' department and having annual salary greater than 1000000.2. Use Joins. Tables involved are employee, works and department3. Order by is mandatory.
Consider following schema and write query for given statementEmp (eid,ename,city,dname,salary) Project(eid,pid,pname,location)Create tables with Primary Key, foreign key constraints in given schemas.(1) Display name of employees who belongs to Computer department.(2) Display employee id whose name starts from letter J.(3) Display all details of employees whose salary is from 10000 to 20000.(4) Display name of employees who are having maximum salary.(5) Display name of employees whose salary is higher than average salary of the employee.(6) Display name of employees whose project id is 3 and location is Mumbai
Write a query to display the ename of employee who draw the highest salary. In case of multiple records, display the records sorted in ascending order based on ename.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.