Q. Given the following table :
Give the output of following SQL statements:
(i) SELECT MIN(AvgMark) FROM STUDENT WHERE AvgMark < 75;
(ii) SELECT SUM(Stipend) FROM Student WHERE Grade = 'B';
(iii) SELECT AVG(Stipend) FROM Student WHERE Class = '12A';
(iv) SELECT COUNT(DISTINCT) FROM Student ;
Consider this table --
Answer =
(i)
MIN(AvgMark)
|
64.40
|
(ii)
SUM(Stipend)
|
1150.00
|
(iii)
AVG(Stipend)
|
475.00
|
(iv)
ERROR
Because there is no field name in count function.
Thanks
ReplyDeleteWelcome ^_^
Delete(i) must be 64.4 instead of 68.4 right?
ReplyDeleteYes you are right.
DeleteIt is 64.4 !cheak your eyes
Deleteand (iv) is 10 right?
ReplyDeleteWrong !! The error will come.
DeleteError is correct as what to count is missing in the query
DeleteI think it should be 425 in 3rd part
ReplyDeleteNo, AVG give decimal number.
DeleteIn (ii) and (iii) isn't it incorrect if where clause is used? In book it is given WHERE clause can't be used with aggregate functions instead HAVING clause is used.
ReplyDeleteYou are wrong. Having clause necessary when you use group by clause. Otherwise you can use where clause.
DeleteI don't understand (iii) please someone explain it to me.
ReplyDeleteFor first answer, it should be just 64.4
ReplyDeleteNo,
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )