MySQL Forums
Forum List  »  Newbie

Re: struggling with a subquery
Posted by: Peter Brawley
Date: August 30, 2020 09:17AM

> SELECT risk, SUM(w2_wages) as total_wages FROM employees
> WHERE (SELECT risk FROM titles WHERE employee_title=title GROUP BY risk

Is this what you mean?

SELECT t.risk, SUM(e.w2_wages) as total_wages
FROM employees e
JOIN titles t ON e.employee_title=t.title
GROUP BY risk;



Edited 1 time(s). Last edit at 08/30/2020 12:58PM by Peter Brawley.

Options: ReplyQuote


Subject
Written By
Posted
August 30, 2020 09:03AM
Re: struggling with a subquery
August 30, 2020 09:17AM
October 12, 2020 03:09AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.