KnowledgeBoat Logo

Informatics Practices

Kunal has entered the following SQL command in the table 'STUDENT' that has TotalMarks as one of the columns:

SELECT * FROM Student;                         #Statement-1

The total number of rows displayed is 20.

Then Kunal enters the following command:

SELECT * FROM STUDENT WHERE TotalMarks < 100;  #Statement-2 

The number of rows displayed is 15.

Kunal then enters the following command:

SELECT * FROM STUDENT WHERE TotalMarks >= 100; #Statement-3

He predicts the output of the above query as 5. Do you agree with Kunal? Give reasons for your answer.

Relational Database

1 Like

Answer

I disagree with Kunal's prediction. Since Statement-1 returns all the rows and columns of the table Student i.e., 20, and Statement-2 returns 15 rows with TotalMarks less than 100, it means 20 - 15 = 5 students have TotalMarks greater than 100. However, Statement-3 returns rows where TotalMarks is greater than or equal to 100, which includes students who scored exactly 100, and we don't know how many students scored exactly 100, so the number of rows returned by Statement-3 will be greater than or equal to 5, but not necessarily exactly 5.

Answered By

2 Likes


Related Questions