sql count function

Posted by suryll on Stack Overflow See other posts from Stack Overflow or by suryll
Published on 2012-04-03T17:09:18Z Indexed on 2012/04/03 17:30 UTC
Read the original article Hit count: 153

Filed under:
|
|

Hi I have three tables and I want to know how much jobs with the wage of 1000 an employee has had

The first SQL query gives me the names of all the employees that has recieved 1000 for a job

SELECT distinct first_name 
FROM employee, job, link 
WHERE job.wage = 1000 
  AND job.job_id = link.job_id and employee.employee_id = link.employee_id;

The second SQL query gives me the total number for all employees of how much jobs they have made for 1000

SELECT count(wage) 
FROM employee, job, link 
WHERE job.wage = 1000 
  AND job.job_id = link.job_id and employee.employee_id = link.employee_id;

I was wondering if there was a way of joining both queries and also making the second for each specific employee???

© Stack Overflow or respective owner

Related posts about mysql

Related posts about sql