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 |
|
brunstrom
Starting Member
3 Posts |
Posted - 2008-10-16 : 10:46:26
|
New here, new to SQL - please be gentle with me I have two tables -Deaths - Year,Weekno,NoOfDeathsBirths - Year,Weekno,NoOf BirthsAssuming I add a 'NoofDeaths' to my 'births' table, how can I populate it with the corresponding data from the Deaths table ?thanks in advance |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2008-10-16 : 10:51:57
|
| insert into Births(OtherColumns, NoofDeaths)select OtherColumns, 1 -- or other value depending on what this column representsfrom deaths,_______________________________________________Causing trouble since 1980Blog: http://weblogs.sqlteam.com/mladenpSpeed up SSMS development: www.ssmstoolspack.com <- version 1.1 out! |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2008-10-16 : 10:53:10
|
| update bset NoOfDeaths=d.NoOfdeathsfrom Births as bjoin Deaths as d on (d.Year=b.Year and d.Weekno=b.Weekno)Planning replaces chance by mistake |
 |
|
|
brunstrom
Starting Member
3 Posts |
Posted - 2008-10-16 : 12:15:53
|
quote: Originally posted by webfred update bset NoOfDeaths=d.NoOfdeathsfrom Births as bjoin Deaths as d on (d.Year=b.Year and d.Weekno=b.Weekno)Planning replaces chance by mistake
looks like what I would have expexcted, so -update bset countgo=tdeaths.countgo from tbirths as b join tdeaths as d on (d.yearno=b.yearno and d.weekno=b.weekno)BUT The multi-part identifier "tdeaths.countgo" could not be bound.que ? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-16 : 12:29:04
|
quote: Originally posted by brunstrom
quote: Originally posted by webfred update bset NoOfDeaths=d.NoOfdeathsfrom Births as bjoin Deaths as d on (d.Year=b.Year and d.Weekno=b.Weekno)Planning replaces chance by mistake
looks like what I would have expexcted, so -update bset countgo=tdeathsd.countgo from tbirths as b join tdeaths as d on (d.yearno=b.yearno and d.weekno=b.weekno)BUT The multi-part identifier "tdeaths.countgo" could not be bound.que ?
modify like above |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-10-17 : 03:46:37
|
quote: Originally posted by brunstrom
quote: Originally posted by webfred update bset NoOfDeaths=d.NoOfdeathsfrom Births as bjoin Deaths as d on (d.Year=b.Year and d.Weekno=b.Weekno)Planning replaces chance by mistake
looks like what I would have expexcted, so -update bset countgo=tdeaths.countgo from tbirths as b join tdeaths as d on (d.yearno=b.yearno and d.weekno=b.weekno)BUT The multi-part identifier "tdeaths.countgo" could not be bound.que ?
Why did you modify the suggested query? MadhivananFailing to plan is Planning to fail |
 |
|
|
brunstrom
Starting Member
3 Posts |
Posted - 2008-10-17 : 08:41:08
|
quote: Originally posted by visakh16
quote: Originally posted by brunstrom
quote: Originally posted by webfred update bset NoOfDeaths=d.NoOfdeathsfrom Births as bjoin Deaths as d on (d.Year=b.Year and d.Weekno=b.Weekno)Planning replaces chance by mistake
looks like what I would have expexcted, so -update bset countgo=tdeathsd.countgo from tbirths as b join tdeaths as d on (d.yearno=b.yearno and d.weekno=b.weekno)BUT The multi-part identifier "tdeaths.countgo" could not be bound.que ?
modify like above
yeaaaa |
 |
|
|
|
|
|
|
|