Click here to Skip to main content
15,904,346 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
-select * from sales

VB
EmpId	Yr	Sales
1	2005	12000.00
1	2006	18000.00
1	2007	25000.00
2	2005	15000.00
2	2006	6000.00
3	2006	20000.00
3	2007	24000.00


I tried this :
SQL
select EMPID,sum(Sales) as [totalsalesemployeewise],AVG(Sales)[avgsalaryemployee] from sales
group by EmpId WITH ROLLUP



i got the result as below :
EMPID	totalsalesemployeewise	avgsalaryemployee
1	55000.00	                   18333.3333
2	21000.00	                   10500.00
3	44000.00	                   22000.00
NULL	120000.00	                   17142.8571


--Now in the last column 120000 is understandable. But how i got this 17142.8571 ?

Kindly help
Posted
Updated 6-Nov-13 20:19pm
v2

1 solution

Simple math. Multiply by the number of rows (7), and you'll see.
 
Share this answer
 
Comments
anurag19289 7-Nov-13 2:41am    
ok ok ....its divide acually

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