sql getting a complex average function -
IM is trying to get it:
"Create a view that is used for all foods For a total consumption list, in a week, this view is used to help feed the food of the zoo's animals. Show food ID and name along with weekly consumption, fed with each meal and average consumption Number of animals going (Weekly consumption
SELECT a.foodID, NAME, b.qtyperday *
Below are my SQL queries: 7 "weekly consumption", COUNT (animal id), avg ((b qtpride * 7) / COUNT (animal id ) "Food consumption from" average consumption "as a food A, feed B WHERE a.foodID = B.FoodIDIIT
I am not able to generate any data for average consumption Which may be the last condition, any solution ??
I believe that you can make every meal There is a need to obtain the number of different animals, for example:
"code", "eggp ((bpr.propardae * 7) / COUNT" (different animal id) Select "code" as a.foodID, NAME, b.qtyperday * 7 as "Weekly Consumption", as COUNT (DISTINCT animalID). As a "Average Consumption" from Food A, feed B WHERE a.foodID = b.foodID GROUP BY FOODID But for further help, I think you need some sample data and some Required posting required is required.
Comments
Post a Comment