| SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it. |
|
|||
Maximum Value - Beginner Question?Hi,
I'm a massive beginner of SQL and just having trouble finishing this problem. I need to get the Max of SUM(price) and output both this and e.name. I'm just not to sure how to go about it, im guessing I need to use a subquerry. SELECT e.name, SUM(price) FROM hsTreatment t, hsVisitHistory V, hsEmployee e WHERE t.treatmentid = v.treatmentid AND e.empid = v.stylistid GROUP BY e.name; |
|
|||
SELECT e.name, max.totalAs I understand the problem is to find the employee with highest price paid for treatment. You can give a try to the above, but bear in mind it was not tested on Oracle so you may have to tweak the syntax a bit. Note that I changed the grouping criteria to employee id (instead of employee name) as this seems natural to me. Beacause of this change we need the outermost select to retrieve the employee name based on the desired id. Please, do not fire the most expensive employee! Please, let me know whether the above worked or not. |
![]() |
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|