Which two queries would work?

View the Exhibit and examine the structure of the PRODUCT_INFORMATION table.
Which two queries would work? (Choose two.)

View the Exhibit and examine the structure of the PRODUCT_INFORMATION table.

Which two queries would work? (Choose two.)

A.
SELECT product_name
FROM product_information
WHERE list_price = (SELECT AVG(list_price)
FROM product_information);

B.
SELECT product_status
FROM product_information
GROUP BY product_status
WHERE list_price < (SELECT AVG(list_price)
FROM product_information);

C.
SELECT product_status
FROM product_information
GROUP BY product_status
HAVING list_price > (SELECT AVG(list_price)
FROM product_information);

D.
SELECT product_name
FROM product_information
WHERE list_price < ANY(SELECT AVG(list_price)
FROM product_information
GROUP BY product_status);



Leave a Reply 11

Your email address will not be published. Required fields are marked *


Anurag

Anurag

the option a and d is correct

miriam

miriam

It seems Answer B will work too.

I ran the query on SQL Developer and successfully queried.

It is confused. Please explain why Answer B is not correct choice. Thanks.

user

user

B. The GROUP BY comes before WHERE. It is incorrect

select sal from emp where sal < any (select avg(sal) from emp group by deptno);
select sal from emp where sal < any (select avg(sal) from emp group by deptno);
select sal from emp group by deptno where sal < any (select avg(sal) from emp);
select sal from emp where sal < (select avg(sal) from emp) group by sal;
select empno from emp where sal < (select avg(sal) from emp) group by empno ;
select deptno from emp where sal < (select avg(sal) from emp) group by deptno ;

user

user

select sal from emp
where sal < (select avg(sal) from emp);

select sal from emp
having sal < (select avg(sal) from emp group by job);

nguimza

nguimza

Hi Please I want to no while the Answer C is false. Plese can you explain to me

hv

hv

C. Aggregate functions (SUM, AVG, MAX, ….) come after HAVING clause. So HAVING list_price > is incorrect. It should be HAVING SUM(list_price) > .. :

alex

alex

a and D is correct.

vinoth

vinoth

A and D is correct

B is incorrect syntax order is wrong

C is incorrect because having should have functions like SUM, COUNT, MIN, MAX, or AVG functions.

dames

dames

C is also incorrect because, if an aggregate function is not used in the HAVING clause, the column used in HAVING must be then also part of the SELECT and GROUP BY clauses.