Tuesday, April 20, 2010

SQL SUM() Function

0 comments
Sql SUM() funtionc is used to get sum of all the values of an expression, to get how many slaes orders have been sent ot each customer or to know that how many visitors have visited the website for each country below are the exampels  has been illustrated.
Syntax:
Select SUM(field_name)
from table
Example #1
Select SUM(qty)
from sales_order
Example #2
Select c.customer, SUM(s.sale_order)
from sales_order s
inner join customer c on s.cust_id=c.custoer_no
group by c.customer
Example # 03
Select c.customer, SUM(s.sale_order)
from sales_order s
inner join customer c on s.cust_id=c.custoer_no
group by c.customer

0 comments: