Unit 6_Summary_SQL Constraints
Unit 6_Summary_SQL Constraints
1. AVG
Syntax:
SELECT AVG(column_name) from table_name WHERE CONDITION;
E.g.
select avg(amount) as "average Amount" from payment;
E.g.
select avg(amount) as "average Amount" from payment where customer_id=341;
2. MAX
E.g.
select max(amount) as "Max amount" from payment;
select max(amount) as "Max amount" from payment where customer_id=341;
3. MIN
E.g.
select min(amount) as "Min amount" from payment;
select min(amount) as " Min amount" from payment where customer_id=341;
4. SUM
E.g.
select sum(amount) as "Total Amount" from payment;
select sum(amount) as " Total Amount " from payment where customer_id=341;
5. COUNT
E.g.
select count(*) as "total tuples" from payment;
select count(customer_id) as "count cust_id" from payment where customer_id=341;