pizzaluver13 Posted November 3, 2010 Share Posted November 3, 2010 I have Henry Books as a table. The columns include: TITLE, PRICE, TYPE(SFI, FIC, MYS), PAPERBACK ('Y' or 'N') so the question is ... Part 1 - For each type of book, list the type and the average price. I don't know how to get average price of a type. Part 2 -consider only paperback books for those types of which the average price is more than $10 any help will be appreciated........... Quote Link to comment https://forums.phpfreaks.com/topic/217697-subquery-problem/ Share on other sites More sharing options...
gizmola Posted November 3, 2010 Share Posted November 3, 2010 I have Henry Books as a table. The columns include: TITLE, PRICE, TYPE(SFI, FIC, MYS), PAPERBACK ('Y' or 'N') so the question is ... Part 1 - For each type of book, list the type and the average price. I don't know how to get average price of a type. Part 2 -consider only paperback books for those types of which the average price is more than $10 any help will be appreciated........... Look into GROUP BY. In your case you want to have groupings by TYPE. Once you GROUP BY you can use summary functions like AVG(). I don't really understand the question for Part 2? Is this homework or a test? Quote Link to comment https://forums.phpfreaks.com/topic/217697-subquery-problem/#findComment-1130043 Share on other sites More sharing options...
pizzaluver13 Posted November 3, 2010 Author Share Posted November 3, 2010 Its practice problems for test review. the second part of the question builds on the first. So after finding the average price for the types we have to go narrow it down further by if it is a papeback and the average price for the type is greater than $10. Quote Link to comment https://forums.phpfreaks.com/topic/217697-subquery-problem/#findComment-1130050 Share on other sites More sharing options...
pizzaluver13 Posted November 3, 2010 Author Share Posted November 3, 2010 I got the first part using SELECT TYPE, AVG(PRICE) FROM BOOK GROUP BY TYPE; now I have to do the 2nd part which asks to repeat the above exercise but consider ONLY paperback books for those types for whcih the average price is more than $10. Quote Link to comment https://forums.phpfreaks.com/topic/217697-subquery-problem/#findComment-1130062 Share on other sites More sharing options...
gizmola Posted November 4, 2010 Share Posted November 4, 2010 Add a WHERE clause with the 2 criteria you need to be concerned about: WHERE AVG(PRICE) > 10 AND PAPERBACK = 'Y' Quote Link to comment https://forums.phpfreaks.com/topic/217697-subquery-problem/#findComment-1130136 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.