wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

SQL: GROUP Functions

Total questions: 97

Worksheet time: 49mins

Name
Class
Date
1.

Which of the following is NOT a GROUP BY function?

a)

MAX

b)

MIN

c)

NVL

d)

AVG

2.

Which of the following functions can be used without GROUP BY clause in SELECT query? (Select all that apply)

a)

COUNT

b)

MAX

c)

MIN

d)

AVG

3.


Which of the following SELECT query returns the department number with maximum salary compensated to an employee? (Consider the table structure as given)

a)

SELECT department_id , max(salary ) FROM employees ;

b)

SELECT department_id , max(salary ) FROM employees GROUP BY department_id ;

c)

SELECT max(salary ) FROM employees GROUP BY department_id ;

d)

SELECT max(salary ) FROM employees ;

4.

Which of the following statements are true about the COUNT function?

a)

The COUNT function counts the number of rows

b)

The COUNT(*) function counts the number of rows with duplicates and NULL values

c)

The COUNT(DISTINCT) function counts the number of distinct rows

d)

COUNT(*) is equivalent to COUNT(ALL)

5.

What are the appropriate data types accepted by GROUP BY functions?

a)

Nested Tables

b)

NUMBER

c)

CLOB

d)

DATE

6.

A table T_COUNT has 12 number values as 1, 2, 3, 32, 1, 1, null, 24, 12, null, 32, null. Predict the output of the below query.

SELECT COUNT (*) FROM t_count;
a)

12

b)

6

c)

9

d)

Throws exception because COUNT function doesn't works with NULL values

7.

A table T_COUNT has 12 number values as 1, 2, 3, 32, 1, 1, null, 24, 12, null, 32, null. Predict the output of the below query.

SELECT COUNT (num) FROM t_count;
a)

12

b)

6

c)

9

d)

Throws exception because COUNT function doesn't works with NULL values

8.

A table T_COUNT has 12 number values as 1, 2, 3, 32, 1, 1, null, 24, 12, null, 32, null. Predict the output of the below query.

SELECT COUNT (ALL num) FROM t_count;
a)

12

b)

6

c)

9

d)

Throws exception because COUNT function doesn't works with NULL values

9.

A table T_COUNT has 12 number values as 1, 2, 3, 32, 1, 1, null, 24, 12, null, 32, null. Predict the output of the below query.

SELECT COUNT (DISTINCT num) FROM t_count;
a)

12

b)

6

c)

9

d)

Throws exception because COUNT function doesn't works with NULL values

10.

What happens when the below query is executed in SQL* Plus?

SELECT COUNT() FROM dual;
a)

Executes successfully and returns no output

b)

Executes successfully and returns output as '1'

c)

Throws exception "ORA-00909: invalid number of arguments"

d)

Throws exception "ORA-00904: "COUNT": invalid identifier" because COUNT function doesn't works with DUAL table

11.

Here are few statements about VARIANCE function in SQL.:

i. The function accepts multiple numeric inputs and returns variance of all the values

ii. The function accepts a number column and returns variance of all column values including NULLs

iii. The function accepts a number column and returns variance of all column values excluding NULLs

Chose the correct combination from the below options:

a)

i and iii

b)

i and ii

c)

ii

d)

iii

12.

Which of the following is NOT a GROUP BY extension in SQL?

a)

GROUP BY

b)

GROUPING SETS

c)

CUBE

d)

ROLLUP

13.
a)

SUM is a group by function because it processes group of employees working in a department

b)

SUM is an aggregate function because it produces one result per group of data

c)

SUM is a single row function because it returns single value for a group i.e. department

d)

SUM is a group by extension function because it uses GROUP BY clause to logically group the departments

14.

Which clause is used to filter the query output based on aggregated results using a group by function?

a)

WHERE

b)

LIMIT

c)

GROUP WHERE

d)

HAVING

15.

Examine the given table structure and predict the outcome of the following query.

a)

The query returns the number of employees who have no commission

b)

The query throws error because equal sign cannot be used when searching for NULL value

c)

The query returns the number of employees in a department whose commission is NULL value

d)

The query throws error because GROUP BY clause is missing in the query

16.

Which of the following statements is true about the group functions?

a)

The MIN function can be used only with numeric data.

b)

The MAX function can be used only with date values.

c)

The AVG function can be used only with numeric data.

d)

The SUM function can't be part of a nested function.

17.

Which of the following is a valid SELECT statement?

a)
SELECT AVG(retail-cost) FROM books GROUP BY category;
b)
SELECT category, AVG(retail-cost) FROM books;
c)
SELECT category, AVG(retail-cost) FROM books WHERE AVG(retail-cost) > 8.56 GROUP BY category;
d)
SELECT category, AVG(retail-cost) Profit FROM books GROUP BY category HAVING profit > 8.56;
18.

Which of the following statements is correct?

a)

The WHERE clause can contain a group function only if the function isn't also listed in the SELECT clause.

b)

Group functions can't be used in the SELECT, FROM, or WHERE clauses.

c)

The HAVING clause is always processed before the WHERE clause.

d)

The GROUP BY clause is always processed before the HAVING clause.

19.

Which of the following is not a valid SQL statement?

a)
SELECT MIN(pubdate) FROM books GROUP BY category HAVING pubid = 4;
b)
SELECT MIN(pubdate) FROM books WHERE category = 'COOKING';
c)
SELECT COUNT(*) FROM orders WHERE customer# = 1005;
d)
SELECT MAX(COUNT(customer#)) FROM orders GROUP BY customer#;
20.

Which of the following statements is correct? (Select all that apply)

a)

The COUNT function can be used to determine how many rows contain a NULL value.

b)

Only distinct values are included in group functions, unless the ALL keyword is included in the SELECT clause.

c)

The WHERE clause restricts which rows are processed.

d)

The HAVING clause determines which groups are displayed in the query results.

21.

Which of the following is a valid SQL statement?

a)
SELECT customer#, order#, MAX(shipdate-orderdate) FROM orders GROUP BY customer# WHERE customer# = 1001;
b)
SELECT customer#, COUNT(order#) FROM orders GROUP BY customer#;
c)
SELECT customer#, COUNT(order#) FROM orders GROUP BY COUNT(order#);
d)
SELECT customer#, COUNT(order#) FROM orders GROUP BY order#;
22.

Which of the following SELECT statements lists only the book with the largest profit?

a)
SELECT title, MAX(retail-cost) FROM books GROUP BY title;
b)
SELECT title, MAX(retail-cost) FROM books GROUP BY title HAVING MAX(retail-cost);
c)
SELECT title, MAX(retail-cost) FROM books;
d)

None of the above

23.

Which of the following statement(s) is/are correct?

1. A group function can be nested inside a group function.

2. A group function can be nested inside a single-row function.

3. A single-row function can be nested inside a group function.

a)

1

b)

2

c)

3

d)

1 and 3

24.

Which of the following functions is used to calculate the total value stored in a specified column?

a)

COUNT

b)

ADD

c)

TOTAL

d)

SUM

25.

Which of the following SELECT statements lists the highest retail price of all books in the Family category?

a)
SELECT MAX(retail) FROM books WHERE category = 'FAMILY';
b)
SELECT MAX(retail) FROM books HAVING category = 'FAMILY';
c)
SELECT retail FROM books WHERE category = 'FAMILY' HAVING MAX(retail);
d)

None of the above

26.

Which of the following functions can be used to include NULL values in calculations?

a)

SUM

b)

NVL

c)

MAX

d)

MIN

27.

Which of the following is not a valid statement?

a)

You must enter the ALL keyword in a group function to include all duplicate values.

b)

The AVG function can be used to find the average calculated difference between two dates.

c)

The MIN and MAX functions can be used on VARCHAR2 columns.

d)

All of the above

28.

Which of the following SQL statements determines how many total customers were referred by other customers?

a)
SELECT customer#, SUM(referred) FROM customers GROUP BY customer#;
b)
SELECT COUNT(referred) FROM customers;
c)
SELECT COUNT(*) FROM customers;
d)
SELECT COUNT(*) FROM customers WHERE referred IS NULL;
29.

Determine the correct order of execution of following clauses in a SELECT statement.

1.SELECT

2.FROM

3.WHERE

4.GROUP BY

5.HAVING

6.ORDER BY

a)

2-3-4-5-1-6

b)

1-2-3-4-5-6

c)

6-5-4-3-2-1

d)

5-4-2-3-1-6

30.

Which of the below clauses is used to group a set of rows based on a column or set of columns?

a)

HAVING

b)

WHERE

c)

GROUP BY

d)

GROUPING

31.

Which of the following group functions can be used for population variance and population standard deviation problems? (Select all that apply)

a)

VAR_POP

b)

STDDEV_POP

c)

VARIANCE

d)

STDDEV_SASMP

32.

Select the positions in a SELECT query where a group function can appear. (Select all that apply)

a)

SELECT statement

b)

WHERE clause

c)

ORDER BY clause

d)

GROUP BY clause

33.

Examine the structure of the EMPLOYEES table as given. Which query will return the minimum salary in each department?

a)
SELECT department_id , MIN (salary ) from EMPLOYEES ;
b)
SELECT department_id , MIN (salary ) from EMPLOYEES  GROUP BY department_id ;
c)
SELECT department_id , MIN (salary ) from EMPLOYEES  GROUP BY salary ;
d)
SELECT department_id , MIN (salary ) from EMPLOYEES  GROUP BY employee_id ;
34.

Examine the structure for the table EMPLOYEES and Interpret the output of the below query

a)

It throws error because only one aggregate function can be used in a query.

b)

It throws error because GROUP BY clause is missing.

c)

It executes successfully and returns same values for both.

d)

It executes successfully where COUNT(*) including NULLs and COUNT(all comm) excluding NULLs.

35.

Which of the following are true about group functions?

a)

You can use group functions in any clause of a SELECT statement.

b)

You can use group functions only in the column list of the select clause and in the WHERE clause of a SELECT statement.

c)

You can mix single row columns with group functions in the column list of a SELECT statement by grouping on the single row columns.

d)

You can pass column names, expressions, constants, or functions as parameter to an group function.

36.

Examine the structure of the table EMPLOYEES as given. You want to create a "emp_dept_sales" view by executing the following SQL statements. Which statement is true regarding the execution of the above statement?

a)

The view will be created and you can perform DLM operations on the view

b)

The view will not be created because the join statements are not allowed for creating a view

c)

The view will not be created because the GROUP BY clause is not allowed for creating a view

d)

The view will be created but no DML operations will be allowed on the view

37.

Which of the following statements are true regarding views? (Select all that apply)

a)

A sub query that defines a view cannot include the GROUP BY clause

b)

A view is created with the sub query having the DISTINCT keyword can be updated

c)

A Data Manipulation Language (DML) operation can be performed on a view that is created with the sub query having all the NOT NULL columns of a table

d)

A view that is created with the sub query having the pseudo column ROWNUM keyword cannot be updated

38.

Examine the table structure as given.

a)

WHERE

b)

SELECT

c)

ORDER BY

d)

GROUP BY

39.

Examine the table structure as given. Which of the below SELECT query will display the maximum and minimum salary earned by each job category?

a)
SELECT job, MAX(salary ), MIN (salary ) FROM employees  GROUP BY department_id ;
b)
SELECT job, MAX(salary ), MIN (salary ) FROM employees  GROUP BY job;
c)
SELECT job, MAX(salary ), MIN (salary ) FROM employees ;
d)

Two aggregate functions cannot be used together in SELECT statement.

40.

Consider the table structure as given.

a)

It executes successfully and generates the required result.

b)

It produces an error because COUNT(*) should be specified in the SELECT clause also.

c)

It executes successfully but produces no result because COUNT(prod_id) should be used instead of COUNT(*).

d)

It produces an error because COUNT(*) should be only in the HAVING clause and not in the WHERE clause.

41.

Examine the table structure as given.

a)

It executes successfully and lists the count of employees under each job category but ignores the HAVING clause since "salary " is not in GROUP BY clause.

b)

It throws error because HAVING clause is invalid.

c)

It throws error because "salary " is not included in the GROUP BY clause.

d)

It executes successfully and lists the count of employees under each category having sum of salary greater than 5000.

42.

What is true of using group functions on columns that contain NULL values?

a)

Group functions on columns ignore NULL values.

b)

Group functions on columns returning dates include NULL values.

c)

Group functions on columns returning numbers include NULL values.

d)

Group functions on columns cannot be accurately used on columns that contain NULL values.

43.

Which of the following statetments are true about the usage of GROUP BY columns in a subquery?

a)

Subqueries can contain GROUP BY and ORDER BY clauses.

b)

Subqueries cannot contain GROUP BY and ORDER BY clauses.

c)

Subqueries can contain ORDER BY but not the GROUP BY clause.

d)

Subqueries cannot contain ORDER BY but can have GROUP BY clause.

44.

Predict the outcome of the below query

SELECT avg(max(salary ))
FROM employees 
GROUP BY department_id 
HAVING avg(max(salary ))>100;
a)

It executes successfully.

b)

It gives an error because the HAVING clause is not valid.

c)

It gives an error because the GROUP BY expression is not valid.

d)

It gives an error because aggregate functions cannot be nested in SELECT statement.

45.

Predict the output of the below query

SELECT avg(salary ), department_id 
FROM employees 
GROUP BY department_id ;
a)

It gives error because an aggregate function cannot appear just after SELECT clause.

b)

It gives error because GROUP BY clause is invalid.

c)

It executes without errors but produces no output.

d)

It executes successfully and gives average salary in each department.

46.

Predict the output of the below query

SELECT lower(job),avg(salary )
FROM employees 
GROUP BY upper(job);
a)

It executes successfully and displays "job" in lower case.

b)

It executes successfully but display "job" in original case.

c)

It throws error because singe row and aggregate functions cannot be used together.

d)

It throws error because case conversion in the SELECT list mismatches with the case conversion GROUP BY clause.

47.

Which of the below query executes successfully? (Select all that apply)

a)
SELECT employee_id , COUNT(hiredate-sysdate) FROM employees ;
b)
SELECT AVG(salary ), MAX(salary ) FROM employees ;
c)
SELECT AVG(salary ), MAX(salary ) FROM employees  GROUP BY department_id ;
d)
SELECT AVG(hiredate) FROM employees ;
48.

Identify the error in the below SELECT statement.

SELECT department_id , AVG (salary )
FROM employees 
GROUP BY department_id 
HAVING department_id  > 10;
a)

It executes successfully and displays average salary of departments higher than 10.

b)

It throws error because non aggregated column cannot be used in HAVING clause.

c)

It executes successfully but displays wrong result for the departments.

d)

It throws error because HAVING clause must be placed before GROUP BY clause.

49.

Predict the output of the below query

SELECT department_id , AVG (salary )
FROM employees 
GROUP BY department_id 
HAVING (department_id >10 and AVG(salary )>2000);
a)

It throws error because multiple conditions cannot be given in HAVING clause.

b)

It throws error because a non aggregate column cannot be used in HAVING clause.

c)

It executes successfully and displays average salary of department higher than 10 and greater than 2000.

d)

It executes successfully but no result is displayed.

50.

Which of the following group functions can be used with DATE values? (Select all that apply)

a)

AVG

b)

MIN

c)

SUM

d)

COUNT

51.

Which of the following statements are true? (Select all that apply)

a)

AVG and SUM can be used only with numeric data types.

b)

STDDEV and VARIANCE can be used only with numeric data types.

c)

MAX can be used with LONG data type.

d)

MAX and MIN cannot be used with LOB or LONG data types.

52.

Examine the table structure as given.

a)

Multiple aggregate functions cannot be used in a single SELECT query

b)

GROUP BY clause is invalid

c)

COUNT function cannot be used with DATE values

d)

No errors and it executes successfully

53.

Which of the following group function can be used with LOB data types?

a)

MAX

b)

MIN

c)

COUNT

d)

None of these

54.

Examine the table structure as given.

a)

Both the queries produce same result

b)

Query - 1 and Query - 2 produce different results because Query-1 considers NULL values of COMM and Query-2 substitutes NULL values of COMM with zero

c)

Query - 1 produces error because COMM has NULL values

d)

Query - 2 produces error because NVL cannot be nested with aggregate function.

55.

Choose the correct statements about the GROUP BY clause. (Select all that apply)

a)

Column alias can be used in the GROUP BY clause.

b)

GROUP BY column must be in the SELECT clause.

c)

GROUP BY clause must appear together with HAVING clause a SELECT query.

d)

GROUP BY clause must appear after WHERE clause in a SELECT query.

56.

Examine the table structure as given.

a)

It throws error because GROUP BY column list doesn't matches with SELECT column list.

b)

It executes successfully and produces average salary of a job category in each department.

c)

It executes successfully and produces average salary for a department in each job category.

d)

It throws error because GROUP BY and ORDER BY clause have different list of columns.

57.

Which clause should you use to exclude group results in a query using group functions?

a)

WHERE

b)

HAVING

c)

GROUP BY

d)

ORDER BY

58.

Predict the outcome of the below query

SELECT department_id ,avg(salary )
FROM employees 
HAVING avg(salary )>2000
GROUP BY department_id 
ORDER BY department_id 
a)

It executes successfully.

b)

It throws error because HAVING clause precedes the GROUP BY clause.

c)

It throws error because HAVING clause uses the aggregate function.

d)

It executes but no results are displayed because HAVING clause precedes the GROUP BY clause.

59.

Predict the outcome of the below query

SELECT department_id , COUNT(first_name )
FROM employees 
WHERE job IN ('SALESMAN','CLERK','MANAGER','ANALYST')
GROUP BY department_id 
HAVING AVG(salary ) BETWEEN 2000 AND 3000;
a)

It returns an error because the BETWEEN operator cannot be used in the HAVING clause.

b)

It returns an error because WHERE and HAVING clauses cannot be used in the same SELECT statement.

c)

It returns an error because WHERE and HAVING clauses cannot be used to apply conditions on the same column.

d)

It executes successfully.

60.

Which statements are true regarding the WHERE and HAVING clauses in a SELECT statement? (Select all that apply)

a)

The HAVING clause can be used with group functions in subqueries.

b)

The WHERE clause can be used to exclude rows after dividing them into groups.

c)

The WHERE clause can be used to exclude rows before dividing them into groups.

d)

The WHERE and HAVING clauses can be used in the same statement only if they are applied to different columns in the table.

61.

Predict the outcome of the below query.

SELECT department_id , avg(salary )
FROM employees 
HAVING avg(salary ) > min(salary )
GROUP BY department_id ;
a)

It throws an error because the aggregate functions used in HAVING clause must be in SELECT list.

b)

It throws an error because the HAVING clause appears before GROUP BY clause.

c)

It displays the departments whose average salary is greater than the minimum salary of the department.

d)

It displays the departments whose average salary is greater than the minimum salary of the organization.

62.

Interpret the output of the below query.

SELECT SUM(AVG(LENGTH(first_name )))
FROM employees  
GROUP BY department_id ;
a)

It calculates the sum of averages of length of employee's name in each department.

b)

It calculates the average length of employee's name in each department.

c)

It throws error because single row function cannot be used with group functions.

d)

It throws error because group column DEPARTMENT_ID is not used in the SELECT list.

63.

Up to how many levels, the group functions can be nested?

a)

1

b)

2

c)

3

d)

No limits

64.

What is the limit of number of groups within the groups created by GROUP BY clause?

a)

1

b)

2

c)

3

d)

No limits

65.

Choose the correct statements about the HAVING clause. (Select all that apply)

a)

The HAVING clause is an optional clause in SELECT statement.

b)

The HAVING clause is a mandatory clause if SELECT statement uses a GROUP BY clause.

c)

The HAVING clause can appear in a SELECT statement only if it uses a GROUP BY clause.

d)

The HAVING clause is a mandatory clause if SELECT statement uses a GROUP BY clause.

66.

What is the output of the below query.

SELECT count(*) FROM dual GROUP BY dummy;
a)

1

b)

0

c)

NULL

d)

Throws error because group functions cannot be applied on DUAL table.

67.

What is the output of the below query?

SELECT SUM (salary ) FROM employees ;
a)

NULL

b)

14000

c)

19000

d)

0

68.

What is the output of the below query?

SELECT AVG (salary ) FROM employees ;
a)

100

b)

736.84

c)

NULL

d)

0

69.

What is the output of the below query?

SELECT AVG (nvl(salary ,0)) FROM employees ;
a)

1000

b)

NULL

c)

736.84

d)

0

70.

What is the output of the below query?

SELECT VARIANCE (salary ) FROM employees ;
a)

100

b)

0

c)

NULL

d)

204678.36

71.

What is the output of the below query?

SELECT VARIANCE (nvl(salary ,0)) FROM employees ;
a)

1000

b)

0

c)

NULL

d)

204678.36

72.

What is the output of the below query?

SELECT STDDEV (salary ) FROM employees ;
a)

1

b)

1000

c)

0

d)

NULL

73.

What is the output of the below query?

SELECT STDDEV (nvl(salary ,0)) FROM employees ;
a)

0

b)

452.41

c)

1000

d)

NULL

74.

What is the output of the below query?

SELECT COUNT(*), COUNT(salary) FROM employees ;
a)

19, 19

b)

14, 19

c)

19, 14

d)

14, 14

75.

Examine the table structure as given. Which of the below query will give the department who have more than 5 employees working in it?

a)
SELECT department_id  FROM employees  WHERE COUNT(*) > 5 GROUP BY department_id ;
b)
SELECT department_id  FROM employees  HAVING COUNT(*) > 5;
c)
SELECT department_id  FROM employees  GROUP BY employee_id  HAVING COUNT(*) > 5;
d)
SELECT department_id  FROM employees  GROUP BY department_id  HAVING COUNT(*) > 5;
76.

Which of the following are true about the CUBE extension of GROUP BY?

a)

Enables performing multiple GROUP BY clauses with a single query.

b)

Performs aggregations for all possible combinations of columns included.

c)

Performs increasing levels of cumulative subtotals, based on the provided column list.

d)

None of the above

77.

Which line of the SELECT statement is used to restrict the number of records the query processes?

a)

1

b)

3

c)

4

d)

5

78.

Which line of the SELECT statement is used to restrict groups displayed in the query results?

a)

1

b)

3

c)

4

d)

5

79.

Which line of the SELECT statement is used to group data stored in the database?

a)

1

b)

3

c)

4

d)

5

80.

Which clause must be included for the query to execute successfully?

a)

1

b)

3

c)

4

d)

5

81.

What is the purpose of using COUNT(*) in the SELECT query?

a)

The number of records in the specified tables

b)

The number of orders placed by each customer

c)

The number of NULL values in the specified tables

d)

The number of customers who have placed an order

82.

Which of the following functions can be used to determine the earliest ship date for all orders recently processed by JustLee Books?

a)

COUNT function

b)

MAX function

c)

MIN function

d)

STDDEV function

83.

Which of the following is not a valid SELECT statement?

a)
SELECT STDDEV(retail) FROM books;
b)
SELECT AVG(SUM(retail)) FROM orders NATURAL JOIN orderitems NATURAL JOIN books GROUP BY customer#;
c)
SELECT order#, TO_CHAR(SUM(retail),'999.99') FROM orderitems JOIN books USING (isbn) GROUP BY order#;
d)
SELECT title, VARIANCE(retail-cost) FROM books GROUP BY pubid;
84.

Which of the below statements are true about the nesting of group functions? (Select all that apply)

a)

The inner most function is resolved first.

b)

Oracle allows nesting of group function up to 3 levels.

c)

Single row functions can be nested with group functions.

d)

Oracle allows nesting of group function up to 2 levels.

85.

What are the statistical group functions in Oracle? (Select all that apply)

a)

AVG

b)

STDDEV

c)

VARIANCE

d)

STATS

86.

If the SELECT list contains a column and a group functions, which of the following clause must be mandatorily included?

a)

ORDER BY

b)

HAVING

c)

GROUP BY

d)

None of these

87.

Examine the table structure as given. What is the best explanation as to why this SQL statement will NOT execute?

SELECT department_id "Department", AVG (salary)"Average"
FROM employees
GROUP BY Department;
a)

Salaries cannot be averaged as not all the numbers will divide evenly.

b)

You cannot use a column alias in the GROUP BY clause.

c)

The GROUP BY clause must have something to GROUP.

d)

The department id is not listed in the departments table.

88.

Which of the following data types are compatible with AVG, SUM, VARIANCE, and STDDEV functions?

a)

Only numeric data types

b)

Integers only

c)

Any data type

d)

All except numeric

89.

Which of the below query will display the number of distinct job categories working in each department?

a)
SELECT department_id , COUNT(DISTINCT job) FROM employees  GROUP BY job;
b)
SELECT department_id , COUNT(job) FROM employees  GROUP BY employee_id ;
c)
SELECT department_id , COUNT(job) FROM employees  GROUP BY department_id ;
d)
SELECT department_id , COUNT(DISTINCT job) FROM employees  GROUP BY department_id ;
90.

Evaluate this SQL statement:

SELECT employee_id , first_name , department_id , SUM(salary )
FROM employees 
WHERE salary  > 1000
GROUP BY department_id , employee_id , first_name 
ORDER BY hiredate;

Why will this statement cause an error?

a)

The HAVING clause is missing.

b)

The WHERE clause contains a syntax error.

c)

The SALARY column is NOT included in the GROUP BY clause.

d)

The HIRE_DATE column is NOT included in the GROUP BY clause.

91.

Which of the following statements is true about the GROUP BY clause? (Select all that apply)

a)

To exclude rows before dividing them into groups using the GROUP BY clause, you use should a WHERE clause.

b)

You must use the HAVING clause with the GROUP BY clause.

c)

Column alias can be used in a GROUP BY clause.

d)

By default, rows are not sorted when a GROUP BY clause is used.

92.

Examine the table structure as given. Interpret the outcome of the below query.

SELECT department_id , MIN (hiredate)
FROM employees 
GROUP by department_id ;
a)

The earliest hire date in the organization.

b)

The latest hire date in the organization.

c)

The earliest hire date in a department.

d)

The latest hire date in a department.

93.

Which statement about group functions is true?

a)

Group functions except COUNT(*), ignore null values.

b)

A query that includes a group function in the SELECT list must include a GROUP BY clause.

c)

Group functions can be used in a WHERE clause.

d)

Group functions can only be used in a SELECT list.

94.

Which of the following clauses represent valid uses of group functions? (Select all that apply)

a)

GROUP BY MAX(salary)

b)

ORDER BY AVG(salary)

c)

HAVING MAX(salary) > 10000

d)

SELECT AVG(NVL(salary, 0))

95.

Which of the following statements are true about the GROUP BY clause? (Select all that apply)

a)

The last column listed in the GROUP BY clause is the most major grouping.

b)

The first column listed in the GROUP BY clause is the most major grouping.

c)

A GROUP BY clause cannot be used without an ORDER BY clause.

d)

The GROUP BY clause do not ensure the sorting of output.

96.

What is difference between WHERE clause and HAVING clause? (Select all that apply)

a)

WHERE clause restrict rows before grouping while HAVING clause restricts groups.

b)

WHERE clause cannot contain a group function but HAVING clause can have.

c)

WHERE clause can join multiple conditions using AND or OR operators but HAVING clause cannot.

d)

WHERE clause can appear in SELECT query without GROUP BY clause but HAVING clause cannot.

97.

Examine the table structure as given. Predict the outcome of the below query.

SELECT department_id ,job,count(*)
FROM employees 
GROUP BY department_id ,job
ORDER BY department_id ,count(*);
a)

It executes successfully.

b)

It throws error because ORDER BY clause is invalid.

c)

It throws error because GROUP BY clause is invalid.

d)

It throws error because GROUP BY and ORDER BY clause cannot be used together.