|Feb 22, 2013, 05:07 PM||#1|
Math in SQL? (HW)
I haven't even had 3 hours of hands on time with SQL yet, so I'm sorry if this comes off sounding like a very noobish question, but I can't figure out what I need to do to take the number returned by this query:
SELECT description, deaths1 FROM who.deaths INNER JOIN who.icd9 ON who.deaths.cause = who.icd9.cause where sex = 2 and country in (SELECT country FROM who.country where country_name like '%united kingdom%') and ryear = 1980 and deaths1 > 0 group by who.icd9.cause order by deaths1 desc limit 1;
Specifically, the question from my homework assignment is
I can't make what I've already written a subquery, because MySQL complains that it doesn't support limits inside of subqueries.
Alright, I can separately find the sum of all UK female deaths from 1980 with this query:
SELECT SUM(deaths1) deaths1 FROM who.deaths where sex = 2 and country in (SELECT country FROM who.country where country_name like '%united kingdom%') and ryear = 1980;
Last edited by ArtOfWarfare; Feb 22, 2013 at 09:53 PM.
|Thread Tools||Search this Thread|
All times are GMT -5. The time now is 07:43 AM.