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 |
|
sureshsmanian
Starting Member
31 Posts |
Posted - 2009-10-22 : 11:42:10
|
| hi I have two tables.Employee ( Empno - PK, Empname)LeaveTable (Leavetype, Empno - FK(ref. employee table), no_of_days)I needed to display the followingEmpno Empname Total number of days(total leave)----- ------- ----------------- -------- -------Thanks in advanceRegardsSSM |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2009-10-22 : 11:44:25
|
| What have you tried so far? |
 |
|
|
sureshsmanian
Starting Member
31 Posts |
Posted - 2009-10-22 : 12:06:43
|
| I have tried this querySelect a.empno, sum(a.no_of_days), b.empname from leavetable ainner join employee bon a.empno = b.empnogroup by a.empno;i got the error :Column 'Employee.EmpName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.Thanks |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-10-22 : 12:48:57
|
quote: Originally posted by sureshsmanian I have tried this querySelect a.empno, sum(a.no_of_days), b.empname from leavetable ainner join employee bon a.empno = b.empnogroup by a.empno, b.empnamei got the error :Column 'Employee.EmpName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.Thanks
modify like below |
 |
|
|
sureshsmanian
Starting Member
31 Posts |
Posted - 2009-10-25 : 04:01:25
|
| Thanks. It is working fine.RgdsSSM |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-10-27 : 13:48:38
|
| welcome |
 |
|
|
|
|
|