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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-12-10 : 09:23:05
|
| halmet writes "im trying to build a store procedure that do the following.I have two tables; TableA has two fields (partID and Price) and TableB has also two fields( PartID and Price). There are some identical (partID) records but not all of them. In other word, I have partID 66 in TableA and I also have partID 66 in TableB but each one has different price. I’m trying to retrieve all the records who has unique partID with its price and retrieve other records(idenitical partID) without duplicating the PartID and retrieve the lowest price between the two tables where identical partID found. And then insert PartID(unique) and the Price to the new table(TableC.please email me if the the question is not clear enough!(halmet@hotmail.com)Your help is very much appreciated halmet" |
|
|
izaltsman
A custom title
1139 Posts |
Posted - 2001-12-10 : 09:35:54
|
| Is this what you need?insert into tablecSELECT partid, min(Price)FROM (select partid, price from tablea union all select partid, price from tableb) as aGROUP by partid |
 |
|
|
|
|
|