SELECT category, type, AVG(price)
FROM products GROUP BY category, type ORDER BY 1, 2

If there are three distinct categories in the "products"
table, and each one has five different types, how many rows
are returned by the query above?

1. 1 row
2. 3 rows
3. 5 rows
4. 8 rows
5. 15 rows

Answer Posted / sreeharibabu

create table products (category varchar2(30), type varchar2(20) ,price number ) ;

insert into products values('c1','t1',100);
insert into products values('c1','t2',200);
insert into products values('c1','t3',300);
insert into products values('c1','t4',400);
insert into products values('c1','t5',500);

insert into products values('c2','t1',100);
insert into products values('c2','t2',200);
insert into products values('c2','t3',300);
insert into products values('c2','t4',400);
insert into products values('c2','t5',500);

insert into products values('c3','t1',100);
insert into products values('c3','t2',200);
insert into products values('c3','t3',300);
insert into products values('c3','t4',400);
insert into products values('c3','t5',500);

select * from products ;

SELECT category, type, AVG(price)
FROM products GROUP BY category, type ORDER BY 1 ;

3 *5 => 15 rows

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the 3 types of behavioral triggers?

667


what is a database lock ? : Sql dba

594


Explain what is sql?

610


What are different categories of sql commands?

636


What is the unique index?

525






How would you pass hints to the sql processor?

532


How do I quit sql?

502


What trigger means?

567


What are few of the schema objects that are created using PL/SQL?

563


What is asqueryable?

533


What is snowflake sql?

582


Why do we need sharding?

529


Can we want to pass a parameter payroll_id to this external pl/sql function, how do we do it?

562


What are the events on which a database trigger can be based?

598


What is a dirty read sql?

487