Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

1. Which of the following is not a built in aggregate function in SQL?
a) avg
b) max
c) total
d) count

View Answer

Answer: c [Reason:] SQL does not include total as a built in aggregate function. The avg is used to find average, max is used to find the maximum and the count is used to count the number of values.

2. Observe the given SQL query and choose the correct option.

SELECT branch_name, COUNT (DISTINCT customer_name) 
FROM depositor, account 
WHERE depositor.account_number = account.account_number 
GROUP BY branch_id

a) The query is syntactically correct but gives the wrong answer
b) The query is syntactically wrong
c) The query is syntactically correct and gives the correct answer
d) The query contains one or more wrongly named clauses.

View Answer

Answer: b [Reason:] The query is syntactically wrong. The attribute in the group by clause must be one of the attributes specified in the select clause.

3. State true or false: SQL does not permit distinct with count(*)
a) True
b) False

View Answer

Answer: a [Reason:] SQL does not permit distinct with count(*) but the use of distinct is allowed with max and min.

4. We apply the aggregate function to a group of sets of tuples using the _______ clause.
a) group by
b) group
c) group set
d) group attribute

View Answer

Answer: a [Reason:] We apply the aggregate function to a group of sets of tuples using the group by clause. The group by clause must always be used whenever we are willing to apply the aggregate function to a group of sets of tuples.

5. Choose the correct option regarding the query

SELECT branch_name, COUNT (DISTINCT customer_name) 
FROM depositor, account 
WHERE depositor.account_number = account.account_number 
       GROUP BY branch_id
       HAVING avg(balance) = 10000;

a) The having clause checks whether the query result is true or not
b) The having clause does not check for any condition
c) The having clause allows only those tuples that have average balance 10000
d) None of the mentioned

View Answer

Answer: c [Reason:] The having clause is used to check for conditions that need to be set on aggregate functions.

6. The _____ aggregation operation adds up all the values of the attribute
a) add
b) avg
c) max
d) sum

View Answer

Answer: d [Reason:] The sum aggregation operation adds up all the values of the specified attribute. There does not exist any aggregation such as add.

7. State true or false: Any attribute which is present in the having clause without being aggregated must not be present in the group by clause.
a) True
b) False

View Answer

Answer: b [Reason:] Any attribute which is present in the having clause without being aggregated must be present in the group by clause. Otherwise, the query is considered to be erroneous.

8. State true or false: We can rename the resulting attribute after the aggregation function has been applied
a) True
b) False

View Answer

Answer: a [Reason:] Yes, we can rename the resulting attribute after the aggregation function has been applied by using a specific keyword.

9. Which keyword is used to rename the resulting attribute after the application of the aggregation function?
a) rename
b) as
c) replace
d) to

View Answer

Answer: b [Reason:] The “as” keyword is used to rename the resulting attribute after the aggregation function has been applied. Just like any other renaming operation, the as keyword simplifies the name of the relation.

10. What values does the count(*) function ignore?
a) Repetitive values
b) Null values
c) Characters
d) Integers

View Answer

Answer: b [Reason:] The count(*) aggregation function ignores null values while calculating the number of values in a particular attribute.