COMPUTER SCIENCE AND ENGINEERING
SQL
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
SELECT COLUMNS(*) FROM Persons
|
|
SELECT COUNT(*) FROM Persons
|
|
SELECT NO(*) FROM Persons
|
|
SELECT LENGTH(*) FROM Persons
|
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’;