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 |
|
newuser123
Starting Member
7 Posts |
Posted - 2010-06-25 : 05:25:58
|
| I have 2 tables with following data T1eid month sal1 jan 1001 feb 1002 jan 2002 feb 2003 jan 3003 feb 3003 mar 3001 mar 1004 jan 400T2eid dept3 ad2 HR1 IT4 ITI want the dept wise salary.plz tell me the query how i can ???? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-06-25 : 05:29:06
|
use INNER JOIN on the 2 table on column eidand then use sum() on the salary with group by dept KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
newuser123
Starting Member
7 Posts |
Posted - 2010-06-25 : 05:42:13
|
| can u plz tell me the query..i am using the same logic but not returning proper data |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-06-25 : 05:47:45
|
can you post your query ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
newuser123
Starting Member
7 Posts |
Posted - 2010-06-25 : 05:50:06
|
| select sum(t1.sal)from t1 t1 where eid in(select eid from t2 t2where t2.eid = t1.eid )i want dept also |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-06-25 : 05:54:42
|
quote: Originally posted by khtan use INNER JOIN on the 2 table on column eidand then use sum() on the salary with group by dept KH[spoiler]Time is always against us[/spoiler]
select t2.dept, sum(t1.sal)from t1 inner join t2 on t1.eid = t2.eidgroup by t2.dept KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|