MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

SQL

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
With SQL, how can you return the number of records in the “Persons” table?
A
SELECT COLUMNS(*) FROM Persons
B
SELECT COUNT(*) FROM Persons
C
SELECT NO(*) FROM Persons
D
SELECT LENGTH(*) FROM Persons
Explanation: 

Detailed explanation-1: -Use the COUNT aggregate function to count the number of rows in a table. This function takes the name of the column as its argument (e.g., id ) and returns the number of rows for this particular column in the table (e.g., 5).

Detailed explanation-2: -The COUNT() function returns the number of rows that matches a specified criterion.

Detailed explanation-3: -COUNT(*) with GROUP BY returns the number of rows in each group. This includes NULL values and duplicates. COUNT(ALL <expression>) evaluates expression for each row in a group, and returns the number of nonnull values.

Detailed explanation-4: -The COUNT (*) function returns the number of rows that satisfy the WHERE clause of a SELECT statement. The following example finds how many rows in the stock table have the value HRO in the manu code column: SELECT COUNT(*) FROM stock WHERE manu code = ‘HRO’;

There is 1 question to complete.