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 |
What is union and union all keyword in sql?
What is sql exception?
Explain the select statement in sql?
Is sql low level language?
What is Difference Between Unique and Primary Key Constraints?
What is different between union and minus?
i have a customer table. trans_id trans_date trans_amt debit_credit_indicator 001 01-JAN-13 1099 cr 001 12-JAN-13 500 db 002 24-FEB-13 400 db 002 23-MAR-13 345 cr 001 18-APR-13 800 cr 002 15-MAR-13 600 db 001 12-FEB-13 200 cr i want like this output. trans_id trans_amt debit_credit_indicator i want get highest credit amount and lowest credit amount and highest debit amount and lowest debit amount for each trans_id. pls give me answer. i want urgent
How do I install microsoft sql?
How many scalar data types are supported in pl/sql?
What is the primary key?
how to saw triggers output in pl/sql database?
What is left join in postgresql?