Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all experts,
i have 1 table (Sales Customer). This table contains customer info and invoice info.
in June 2013, this table has 550 lines and if i district customer, it has 5 customers.
I want to count for each customer. Ex: Customer A how many invoices he bought, Customer B How many invoices he bought.......So Does anybody know how i can count for each customers?

Thanks

TONY
Posted

Try this:
SQL
SELECT COUNT(1) AS InvCount
FROM CustomerSales
GROUP BY CustomerID
 
Share this answer
 
you can use group by clause.

Select count(columnname) from tblname
group by columnname

Ex.

select count(empid) from Employee group by EMPID
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900