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 |
akashenk
Posting Yak Master
111 Posts |
Posted - 2009-02-01 : 01:05:06
|
I have two tables with similar strucrure (below). Table A: ProductPrices...ProductId, ProductPriceTable B: CustomerPriceSpecials... ProductId, ProductPrice, CustomerIdBasically I need to get all of the product prices. If a record exists in the CustomerPriceSpecials table for a given customierId and product id, then I need to retrieve the price from that table. If it doesn't exist, then I need to retireve the price from the ProductPrices Table. I think in SQL 2005, there are some set functions like INtersect that might help me out here. But I don't think these are possible in SQL 2000, and I think there may be an easier way of accomplishing this anyways. Any suggestions? |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-01 : 01:12:39
|
[code]SELECT ProductId, ProductPriceFROM CustomerPriceSpecialsUNION ALLSELECT ProductId, ProductPriceFROM ProductPrices ppLEFT JOIN CustomerPriceSpecials cpsON cps.ProductId=pp.ProductIdWHERE cps.ProductId IS NULL[/code] |
|
|
akashenk
Posting Yak Master
111 Posts |
Posted - 2009-02-01 : 16:17:00
|
Thanks! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-02-01 : 23:24:41
|
welcome |
|
|
|
|
|