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 |
|
altuko
Starting Member
3 Posts |
Posted - 2010-07-28 : 11:38:26
|
| Hi all,i have 3 tables,and i wanna merge them looking at sdatekey and edatekey.Table1sdatekey edatekey title ID10 15 x 12Table2sdatekey edatekey staffstatu reason ID9 12 y a 12Table3sdatekey edatekey level tel address ID5 11 z b c 12i wanna this resultset;sdatekey edatekey title staffstatu reason level address tel5 9 NULL NULL NULL z c b9 10 NULL y a z c b10 11 x y a z c b11 12 x y a NULL NULL NULL 12 15 x NULL NULL NULL NULL NULL |
|
|
Ifor
Aged Yak Warrior
700 Posts |
Posted - 2010-07-28 : 13:08:23
|
| Umm… This looks like homework so I doubt if anyone will do it for you.Try the following approach:1. Use a Number/Tally table to replace the sdatekey and edatekey with the appropriate number of rows with datekey.2. FULL JOIN the results.3. Rollup the results so that consecutive datekeys become one row with sdatekey and edatekey where the other columns are the same. |
 |
|
|
altuko
Starting Member
3 Posts |
Posted - 2010-07-28 : 13:28:01
|
| No that is not homework,it is about my job.i think that is not possible to do that:) |
 |
|
|
altuko
Starting Member
3 Posts |
Posted - 2010-07-28 : 13:31:41
|
| may be u can give some sample code for this.u dont have to do all of that. |
 |
|
|
|
|
|