In: Computer Science
1.
When specifying a column name inside of a COUNT(), what does the function actually count? (E.g., COUNT(name))
a. The number of rows in the column
b.The number of rows in the table
c.The number of non-null rows
d.The number of non-null columns
3. Which SQL clause is used to sort the output?
a.ORDER BY
b.SORT
c.ORDER
d.SORT BY
Which SQL statement is used to extract data from a database?
a.OPEN
b.SELECT
c.GET
d.EXTRACT
The OR operator displays a record if ANY conditions listed are true. The AND operator displays a record if All of the conditions listed are true.
a. True
b.False
1)
Solution) Option b is the correct answer
Explanation: The count() function is SQL returns the number of records in the table. If where clause is used with count() function then it returns the number of rows depending on the where clause condition.Thus, option a,c and d are wrong and option b is correct.
3)
Solution) Option a ORDER BY is the correct answer
Explanation: The ORDER BY clause in SQL sorts the result based on the column name provided and by default the result is sorted in ascending order and by using the keyword DESC the result gets sorted in descending order.For e.g SELECT * from employee order by emp_name would fetch the result sorted by emp_name in ascending order.Thus options b,c and d are incorrect.
4)
Solution)Option b SELECT is the correct answer.
Explanation: The SELECT statement is used to extract data from the database.We can use various conditions such as where clause,joins with select statement to fetch data from database.For e.g SELECT * FROM employee.Thus, option a,c and d are incorrect.
5)
Solution)Option a True is the correct answer
Explanation: The OR operator in SQL returns true if any of the specified criteria is true , for e.g SELECT emp_name from employee where age=18 or salary>5000; would fetch all records where either of the condition matches.For e.g SELECT emp_name from employee where age=18 and salary>5000 would fetch only those employees who satisfy both the conditions.Thus, option a is correct