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 |
|
jose1lm
Yak Posting Veteran
70 Posts |
Posted - 2003-06-27 : 14:04:13
|
| I’m new to SQL and I have been looking around for help on how to acomplish the results that I need.I am trying to join 2 tables.My goal: Have 1 table with the item number not repeating because of different values in ‘House/Mohtq’.Table1 ‘ITEMASA’ITNBR | ITDSC00001 | d250 housing00002 | d250 cableTable2 ‘ITEMBL’ITNBR | HOUSE | MOHTQ00001 | 2 | 30000001 | 3 | 2000001 | M | 500002 | 2 | 000002 | 3 | 4000002 | M | 50etc etcThe way I would like for it to look is like this:ITNBR | ITDSC | HOUSE2 | HOUSE3 | HOUSEM 00001 | d250 housing | 300 | 20 | 500002 | d250 cable | 0 | 40 | 50Any help would be greatly apreciated. Thanks in adv.SQL Server 2000Edited by - jose1lm on 06/27/2003 14:09:37 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-06-27 : 15:33:52
|
| select ITNBR ,ITDSC ,HOUSE2 = (select MOHTQ from ITEMBL b where b.ITNBR = a.ITNBR and b.HOUSE = '2') ,HOUSE3 = (select MOHTQ from ITEMBL b where b.ITNBR = a.ITNBR and b.HOUSE = '3') ,HOUSEM = (select MOHTQ from ITEMBL b where b.ITNBR = a.ITNBR and b.HOUSE = 'M')from ITEMSA a==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
jose1lm
Yak Posting Veteran
70 Posts |
Posted - 2003-06-30 : 16:53:59
|
| Thx nr, that worked great!JLM |
 |
|
|
|
|
|