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 |
|
sam_sh
Starting Member
4 Posts |
Posted - 2009-08-04 : 01:38:08
|
| Hi,I have 2 tables:Table1:ID Subject Date--------------------1 sub1 01/01/092 sub2 01/02/093 sub3 01/03/09Table2:IDTable1 User Number----------------------1 A 51 B 71 C 32 A 102 B 73 A 13 C 6Output (between 2 dates '01/01/09' and '01/02/09):ID Subject sum(number)-------------------------1 sub1 152 sub2 17thanks |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-08-04 : 02:20:13
|
[code]select t1.ID, t1.Subject, sum(t2.Number)from table1 t1 inner join table2 t2 on t1.ID = t2.IDwhere t1.Date between '20090101' and '20090102'group by t1.ID, t1.Subject[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
saran_d28
Starting Member
36 Posts |
Posted - 2009-08-04 : 02:29:49
|
| Hi try this,select id, subject, sum(user_numer) from(SELECT a.id, a.subject, b.user_numberfrom table1 a join table2 bon a.id = b. idand a.date1 between '01-jan-2009' and '02-jan-2009')main group by id, subject--Saravanan |
 |
|
|
sam_sh
Starting Member
4 Posts |
Posted - 2009-08-04 : 13:10:03
|
| Thank you |
 |
|
|
|
|
|