CBSE Class 12 Informatics Practices Question 29 of 90

Querying Using SQL — Question 7

Back to all questions
7
Question

Question 7

Which SQL statement do we use to find out the total number of records present in the table ORDERS ?

  1. SELECT * FROM ORDERS;
  2. SELECT COUNT(*) FROM ORDERS ;
  3. SELECT FIND (*) FROM ORDERS ;
  4. SELECT SUM() FROM ORDERS ;
Answer

SELECT COUNT(*) FROM ORDERS ;

Reason — The COUNT() function in SQL counts the number of rows or records in a table. When used with the asterisk (*), it counts all rows in the table, including duplicates and nulls. Therefore, SELECT COUNT(*) FROM ORDERS will return the total number of records in the ORDERS table.