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
Answers were Sorted based on User's Feedback
Answer / 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 |
Write a query to find second highest salary of an employee.
What is cursor and its types?
what are the different type of sql's statements ? : Sql dba
can we create index on index?
What is the difference between row level and statement level trigger?
Please let me know if UNION ALL and Natural Join does the same operation and are same...
What are stored procedures in mysql?
How many primary keys can a table have?
Is pl sql a scripting language?
what is the use of HASH, LIST partitions?
What is crud stand for?
What is compute?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)