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.

15 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. (i) must be 64.4 instead of 68.4 right?

    ReplyDelete
  2. and (iv) is 10 right?

    ReplyDelete
    Replies
    1. Wrong !! The error will come.

      Delete
    2. Error is correct as what to count is missing in the query

      Delete
  3. I think it should be 425 in 3rd part

    ReplyDelete
    Replies
    1. No, AVG give decimal number.

      Delete
  4. In (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.

    ReplyDelete
    Replies
    1. You are wrong. Having clause necessary when you use group by clause. Otherwise you can use where clause.

      Delete
  5. I don't understand (iii) please someone explain it to me.

    ReplyDelete
  6. For first answer, it should be just 64.4

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post