nerdexam
Oracle

1Z0-061 · Question #10

View the Exhibit and examine the structure of the SALES table. The following query is written to retrieve all those product IDs from the SALES table that have more than 55000 sold and have been…

The correct answer is C. It produces an error because count{*) should be only in the HAVING clause and not in the WHERE clause. Restricting Group Results with the HAVING Clause You use the HAVING clause to specify the groups that are to be displayed, thus further restricting the groups on the basis of aggregate information. In the syntax, group_condition restricts the groups of rows returned to those…

Install and Administer Oracle RAC

Question

View the Exhibit and examine the structure of the SALES table. The following query is written to retrieve all those product IDs from the SALES table that have more than 55000 sold and have been ordered more than 10 times. Which statement is true regarding this SQL statement?

Exhibit

1Z0-061 question #10 exhibit

Options

  • AIt executes successfully and generates the required result.
  • BIt produces an error because count(*) should be specified in the SELECT clause also.
  • CIt produces an error because count{*) should be only in the HAVING clause and not in the WHERE clause.
  • DIt executes successfully but produces no result because COUNT (prod_id) should be used instead

How the community answered

(24 responses)
  • A
    13% (3)
  • B
    4% (1)
  • C
    79% (19)
  • D
    4% (1)

Explanation

Restricting Group Results with the HAVING Clause You use the HAVING clause to specify the groups that are to be displayed, thus further restricting the groups on the basis of aggregate information. In the syntax, group_condition restricts the groups of rows returned to those groups for which the specified condition is true. The Oracle server performs the following steps when you use the HAVING clause: 1. Rows are grouped. 2. The group function is applied to the group. 3. The groups that match the criteria in the HAVING clause are displayed. The HAVING clause can precede the GROUP BY clause, but it is recommended that you place the GROUP BY clause first because it is more logical. Groups are formed and group functions are calculated before the HAVING clause is applied to the groups in the SELECT list. Note: The WHERE clause restricts rows, whereas the HAVING clause restricts groups.

Topics

#GROUP BY#HAVING clause#aggregate functions#WHERE clause

Community Discussion

No community discussion yet for this question.

Full 1Z0-061 Practice