Disclaimer:
Educational Use Only:
The website links provided are to be used strictly for educational and knowledge-gaining purposes only.
No Misuse:
Do not misuse the links or the information contained therein for any commercial, illegal, or unethical activities.
Respect for Websites and Businesses:
Respect the intellectual property and business interests of the websites and their owners. Do not attempt to alter, copy, or redistribute content without proper authorization.
Acknowledge Value of Knowledge:
Recognize and value the knowledge and resources shared by these websites. Use the information responsibly and ethically.
No Endorsement:
The provision of these links does not imply endorsement of the linked sites, their content, or their products and services. Users are responsible for evaluating the suitability and accuracy of the information.
User Responsibility:
By accessing these links, you agree to use the information at your own risk and to comply with all applicable laws and website terms of use.
Overall MCQs for Reference
- Which SQL clause is used to group results based on common values?
a. WHERE
b. ORDER BY
c. GROUP BY
d. SELECT
Answer: c. GROUP BYgyansetu+1 - The GROUP BY clause is commonly used with which type of functions?
a. Mathematical functions
b. Aggregate functions
c. String functions
d. System functions
Answer: b. Aggregate functionsgeeksforgeeks+1 - What does the GROUP BY clause do in an SQL query?
a. Filters rows
b. Sorts results
c. Groups rows based on a column’s values
d. Deletes rows
Answer: c. Groups rows based on a column’s valuessimplilearn+1 - Which of the following is a valid aggregate function used with GROUP BY?
a. ROUND()
b. COUNT()
c. LOWER()
d. LENGTH()
Answer: b. COUNT()testbook+1 - Which SQL clause is typically used to filter grouped results after GROUP BY?
a. WHERE
b. HAVING
c. SELECT
d. ORDER BY
Answer: b. HAVINGmultiple-choice-questions.blogspot+1 - What will the following query return?
SELECT department, AVG(salary) FROM employees GROUP BY department;
a. Average salary per employee
b. Department names only
c. Average salary per department
d. List of employee names
Answer: c. Average salary per departmenttestbook+1 - GROUP BY can be used with how many columns?
a. Only one
b. Maximum two
c. Any number of columns
d. Only numeric columns
Answer: c. Any number of columnshightouch+1 - What keyword must follow GROUP BY for further sorting?
a. ORDER BY
b. SORT BY
c. FILTER BY
d. HAVING
Answer: a. ORDER BYsimplilearn - Which clause must appear after GROUP BY?
a. SELECT
b. HAVING (optional)
c. AND
d. UNION
Answer: b. HAVING (optional)igmguru+1 - If you use GROUP BY with non-aggregated columns not in the clause, what occurs?
a. Syntax error
b. Returns all columns
c. Ignores those columns
d. Continues normally
Answer: a. Syntax errortestbook - What is a primary use of GROUP BY in data analysis?
a. Data fusion
b. Summarizing grouped data
c. Authentication
d. Parsing files
Answer: b. Summarizing grouped datalearnsql+1 - Which aggregate function does NOT ignore NULL values in SQL?
a. COUNT()
b. MAX()
c. SUM()
d. AVG()
Answer: a. COUNT()testbook - What is the result of using GROUP BY on a column with unique values?
a. One group per unique value
b. One group total
c. Combines all rows
d. Syntax error
Answer: a. One group per unique valuew3schools+1 - The HAVING clause is used:
a. Before GROUP BY
b. To filter after grouping
c. Instead of WHERE
d. To order results
Answer: b. To filter after groupingigmguru - Which of these queries is INVALID?
a. SELECT city, SUM(pop) FROM cities GROUP BY city;
b. SELECT city, pop FROM cities GROUP BY city;
c. SELECT city, COUNT(*) FROM cities GROUP BY city;
d. SELECT city, AVG(pop) FROM cities GROUP BY city;
Answer: b. SELECT city, pop FROM cities GROUP BY city;testbook - To count the number of records per category, you use:
a. COUNT()
b. GROUP COUNT
c. SUM()
d. TOTAL()
Answer: a. COUNT(*)simplilearn+1 - What is the general order of SQL clauses?
a. WHERE, SELECT, FROM, GROUP BY
b. SELECT, FROM, WHERE, GROUP BY
c. SELECT, GROUP BY, FROM, WHERE
d. FROM, GROUP BY, SELECT, WHERE
Answer: b. SELECT, FROM, WHERE, GROUP BYgeeksforgeeks+1 - What is the default sorting of GROUP BY output?
a. By group value ascending
b. By aggregate ascending
c. By first column
d. No guaranteed order
Answer: d. No guaranteed ordersimplilearn - Which SQL statement will sum sales for each region?
a. SELECT SUM(sales) FROM regions;
b. SELECT region, SUM(sales) FROM sales GROUP BY region;
c. SELECT region, sales FROM sales;
d. SELECT sales, region FROM sales GROUP BY sales;
Answer: b. SELECT region, SUM(sales) FROM sales GROUP BY region;simplilearn+1 - In Python Pandas, which method is used for grouping data?
a. regroup()
b. collect()
c. groupby()
d. aggregate()
Answer: c. groupby()examveda - The result set of GROUP BY will contain:
a. Duplicate group values
b. Unique groups only
c. Sorted list only
d. No aggregation
Answer: b. Unique groups onlyhightouch+1 - Which function calculates the minimum value in a group?
a. MIN()
b. GREATEST()
c. LOWEST()
d. SMALLEST()
Answer: a. MIN()simplilearn+1 - What does this SQL accomplish?
SELECT gender, COUNT(*) FROM students GROUP BY gender;
a. Counts students of each gender
b. Lists genders only
c. Returns highest student ID
d. Compares grades
Answer: a. Counts students of each gendertestbook+1 - To get the maximum salary from each department:
a. SELECT MAX(salary) GROUP BY department;
b. SELECT department, MAX(salary) FROM employees GROUP BY department;
c. SELECT department, salary FROM employees;
d. SELECT department, MAX(salary) FROM employees;
Answer: b. SELECT department, MAX(salary) FROM employees GROUP BY department;w3resource+1 - Which clause must be used for aggregate filtering?
a. WHERE
b. HAVING
c. IF
d. ON
Answer: b. HAVINGmultiple-choice-questions.blogspot+1 - Which of these will produce an error?
a. SELECT department, COUNT(name) FROM employees GROUP BY department;
b. SELECT department, name FROM employees GROUP BY department;
c. SELECT department, MAX(salary) FROM employees GROUP BY department;
d. SELECT department, AVG(salary) FROM employees GROUP BY department;
Answer: b. SELECT department, name FROM employees GROUP BY department;testbook - Which combination is correct for grouping and aggregating?
a. GROUP BY only
b. GROUP BY with aggregate functions
c. ORDER BY only
d. SELECT only
Answer: b. GROUP BY with aggregate functionshightouch+1 - Using GROUP BY:
a. Returns one value per row
b. Returns one row per group
c. Duplicates original table
d. Deletes all data
Answer: b. Returns one row per groupgeeksforgeeks+1 - Can you use GROUP BY with functions like SUM, COUNT, AVG?
a. Only SUM
b. Only COUNT
c. Yes, all three
d. Only AVG
Answer: c. Yes, all threesimplilearn+1 - After grouping, to filter based on aggregated results, you use:
a. WHERE
b. HAVING
c. SELECT
d. JOIN
Answer: b. HAVINGmultiple-choice-questions.blogspot+1 - Which of the following is TRUE?
a. GROUP BY must follow WHERE
b. GROUP BY must be first
c. GROUP BY follows SELECT
d. GROUP BY is never required
Answer: a. GROUP BY must follow WHEREgeeksforgeeks+1 - For a table of transactions, how to count transactions per day?
a. SELECT date, COUNT() FROM transactions GROUP BY date;
b. SELECT date, SUM(transaction_id) FROM transactions GROUP BY date;
c. SELECT date, transaction_id FROM transactions;
d. SELECT COUNT() FROM transactions;
Answer: a. SELECT date, COUNT(*) FROM transactions GROUP BY date;simplilearn+1 - If the WHERE clause is used with GROUP BY, which executes first?
a. GROUP BY
b. WHERE
c. SELECT
d. HAVING
Answer: b. WHEREgeeksforgeeks+1 - GROUP BY is mandatory in which situation?
a. When using SELECT DISTINCT
b. When using aggregation without grouping
c. When aggregating per group
d. When sorting results
Answer: c. When aggregating per grouphightouch - GROUP BY can be combined with which clause for sorting?
a. ORDER BY
b. SUM()
c. MAX()
d. SELECT DISTINCT
Answer: a. ORDER BYsimplilearn - What is true about NULLs and GROUP BY?
a. NULLs are ignored
b. NULLs become their own group
c. NULLs are always filtered
d. Queries with NULL always fail
Answer: b. NULLs become their own grouptestbook+1 - When grouping by two columns, how are groups formed?
a. By each unique pair
b. By each column independently
c. By first column only
d. By second column only
Answer: a. By each unique pairhightouch+1 - Which is an invalid GROUP BY usage?
a. GROUP BY column1, column2
b. GROUP BY column1
c. GROUP BY column1 + column2
d. GROUP BY aggregate_function
Answer: d. GROUP BY aggregate_functiongeeksforgeeks - Which clause comes last in SQL execution order?
a. GROUP BY
b. HAVING
c. ORDER BY
d. SELECT
Answer: c. ORDER BYsimplilearn - What happens if you omit GROUP BY while using aggregate functions?
a. Syntax error
b. Aggregates over whole table
c. Aggregates not performed
d. Only groups appear
Answer: b. Aggregates over whole tablehightouch+1 - Which Pandas method combines grouping and aggregation?
a. join()
b. groupby().agg()
c. mean()
d. pivot()
Answer: b. groupby().agg()examveda - In SQL, what does this return?
SELECT country, COUNT(customer_id) FROM customers GROUP BY country;
a. List of customer IDs
b. Customer count per country
c. Total customers
d. Customers per city
Answer: b. Customer count per countryw3resource+1 - Can GROUP BY be used without aggregate functions?
a. Always required
b. Yes, but not meaningful
c. No
d. Only in MySQL
Answer: b. Yes, but not meaningfullearnsql+1 - GROUP BY followed by ORDER BY sorts:
a. The grouped result
b. The raw table
c. Only non-group columns
d. The entire database
Answer: a. The grouped resultw3resource+1 - In Pandas, what does df.groupby(‘A’).sum() do?
a. Sums all columns in df
b. Sums grouped by ‘A’
c. Counts unique values
d. Filters only column ‘A’
Answer: b. Sums grouped by ‘A’examveda - Which clause can restrict results before grouping?
a. HAVING
b. WHERE
c. GROUP BY
d. ORDER BY
Answer: b. WHEREgeeksforgeeks+1 - What is the relationship between DISTINCT and GROUP BY?
a. GROUP BY is equivalent to DISTINCT
b. GROUP BY can produce count/sums, DISTINCT cannot
c. DISTINCT is preferred for aggregations
d. Both always required together
Answer: b. GROUP BY can produce count/sums, DISTINCT cannotw3resource+1 - What is the effect of combining GROUP BY and ORDER BY?
a. GROUP BY overrides ORDER BY
b. ORDER BY overrides GROUP BY
c. ORDER BY sorts the grouped result
d. They cannot be combined
Answer: c. ORDER BY sorts the grouped resultplacementpreparation+1 - How does GROUP BY affect the final output of a query?
a. Reduces row count to groups
b. Increases rows
c. Only sorts output
d. Returns all columns
Answer: a. Reduces row count to groupsw3resource+1 - The GROUP BY clause in SQL is primarily used to:
a. Prevent data duplication
b. Summarize data by groups
c. Delete specific rows
d. Sort the results
Answer: b. Summarize data by groupslearnsql+1
- https://www.igmguru.com/blog/sql-mcqs
- https://hightouch.com/sql-dictionary/sql-group-by
- https://www.simplilearn.com/tutorials/sql-tutorial/group-by-in-sql
- https://testbook.com/objective-questions/mcq-on-aggregate-functions–5eea6a0939140f30f369da92
- https://www.gyansetu.in/blog/data-analytics-mcq-quiz-interview-preparation/
- https://www.geeksforgeeks.org/sql/sql-group-by/
- https://multiple-choice-questions.blogspot.com/2015/08/questions-sql-group-by-having.html
- https://www.w3schools.com/sql/sql_groupby.asp
- https://www.sanfoundry.com/sql-questions-answers-sql-group-by/
- https://learnsql.com/blog/group-by-in-sql-explained/
- https://www.w3resource.com/sql-exercises/sql-aggregate-functions.php
- https://www.sisense.com/blog/everything-about-group-by/
- https://www.examveda.com/data-science/practice-mcq-question-on-data-analysis-with-python/?page=5
- https://www.placementpreparation.io/mcq/sql/page/3/
- https://www.sanfoundry.com/1000-data-science-questions-answers/
- https://www.interviewbit.com/data-science-mcq/
- https://www.datawars.io/data-science-project/4cd95998-pandas-grouping-and-aggregation-mcq-challenge
- https://www.scribd.com/document/705848941/Data-Science-MCQ-Questions-and-Answer-PDF
- https://easyexamnotes.com/data-science-mcqs/
- https://www.placementpreparation.io/mcq/data-science/