1 1 vote Found randomly somewhere: i think multiple answers possible? Databases databases sql + – Anu007 1.5k views answer comment Share Follow Print See all 7 Comments 7 7 Comments reply Ashwin Kulkarni commented Jan 2, 2018 reply Follow flag In this case COUNT of single attribute might be different from COUNT of whole table. 2 2 replyShare joshi_nitish commented Jan 2, 2018 reply Follow flag result using SUM and COUNT is always equal to result using AVG if there is atleast one non-NULL value, because all three of SUM, COUNT and AVG ignore NULL values. but there is problem in one case, if all the values are NULL under rating attribute, in this case COUNT=0, SUM=NULL, AVG=NULL 2 2 replyShare Anu007 commented Jan 2, 2018 reply Follow flag yes i think some issue is there., 0 0 replyShare Ashwin Kulkarni commented Jan 2, 2018 reply Follow flag If out of 3 values in rating attr, 1 is null , then COUNT(rating) = 2, but COUNT(whole relation) = 3. Is this Q only related to that "rating" attribute? 0 0 replyShare srestha commented Jan 2, 2018 reply Follow flag still if we find answer b) will be ans 0 0 replyShare Kiran Karwa commented Jan 2, 2018 reply Follow flag Average in SQL is sum of all non-null values/total non-null values? or sum of all non-null values/total values(null+non null) ? 0 0 replyShare Higgs commented Jan 4, 2018 reply Follow flag //Assuming you are aware of the sum() and count(). Avg = sum of non-null values/count of non-null values i.e. Avg <=> sum(column_name)/count(column_name) Eg: .........| Salary| .......... | 500 | | Null | | 300 | Avg(Salary) = 400 <=> sum(Salary) / count(Salary) = 800 / 2 = 400 0 0 replyShare Please log in or register to add a comment.
1 1 vote The answer could be B or C. the twist is in the COUNT function, if count function is applied on whole table, COUNT(*), then the answer will be C. and if the COUNT function is applied on rating attribute, COUNT(rating), then the result will be equal to that of AVERAGE function B. Shobhit Asati (tafr! answered Jan 2, 2018 Shobhit Asati (tafr! comment Share Follow 0 reply Please log in or register to add a comment.