Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
gupta
Starting Member
25 Posts |
Posted - 2011-04-01 : 08:25:01
|
Hi Guys,How are you?, I hope all are fine, Very Good Morning, I have around 3-5 doubts in Aggregate Functions can anybody clarify.The doubts are: 1. Command to get average salary of any 2employees?, here is the employee table.empid ename mgrid sal comm hiredate100 Anil 105 15000 10 1993-01-12 00:00:00.000101 Balu 103 35000 NULL 1992-04-06 00:00:00.000102 Avinash 104 39000 20 1993-02-05 00:00:00.000103 Sumit 104 45000 10 1990-10-11 00:00:00.000104 Chandu 100 40000 30 1993-01-01 00:00:00.000105 Sudhir 103 30000 NULL 1994-04-05 00:00:00.000106 srinu 101 35000 15 2007-06-07 00:00:00.000_________________________________________________________________2. command to add any 2employees salaries?. here is the table.empid ename mgrid sal comm hiredate100 Anil 105 15000 10 1993-01-12 00:00:00.000101 Balu 103 35000 NULL 1992-04-06 00:00:00.000102 Avinash 104 39000 20 1993-02-05 00:00:00.000103 Sumit 104 45000 10 1990-10-11 00:00:00.000104 Chandu 100 40000 30 1993-01-01 00:00:00.000105 Sudhir 103 30000 NULL 1994-04-05 00:00:00.000106 srinu 101 35000 15 2007-06-07 00:00:00.000________________________________________________________________ |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-04-01 : 15:51:11
|
First you have to pick the two rows you are interested in (using TOP keyword). Then, you can use AVG and SUM functions, respectively for average and sum. |
 |
|
|
|
|