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
1 Like
Related Questions
Assertion (A): DISTINCT clause must be used in an SQL statement to eliminate duplicate rows.
Reasoning (R): DISTINCT only works with numeric data type only.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Assertion (A): FLOAT and DOUBLE are data types.
Reasoning (R): Both can hold any number up to 23 digits.
- Both A and R are true and R is the correct explanation of A.
- Both A and R are true but R is not the correct explanation of A.
- A is true but R is false.
- A is false but R is true.
Mr. Shivaya is using a table 'COURSE' with the following columns: COURSE_ID, COURSE_NAME. He needs to display the names of all the courses which end with "SCIENCE". He has written the query mentioned below, which is not giving the desired result.
SELECT COURSE_ID, COURSE_NAME FROM COURSE WHERE COURSE_NAME = '_SCIENCE';
Help Mr. Shivaya to write the correct query.
Ms. Manisha, a veterinarian, created a table 'VETERINARY' with the following columns:
ANIMAL_ID, VACCINATION_DATE, ANIMAL, OWNER_NAME
She wants to see the details of all the animals other than Dog and Cat which she has vaccinated.
She has written the following query:SELECT * FROM VETERINARY WHERE ANIMAL NOT IN ('DOG', 'CAT');
Write a suitable alternate query for producing the same result.