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 |
|
newcents3
Starting Member
3 Posts |
Posted - 2006-08-01 : 15:51:58
|
| I need to lookup 3 different prices, all which are in the same table. Right now the SQL query does an individual select for each of the 3 prices, as they are in a different table:Select part_description, (select top 1 customer_pricefrom std_products_customers spc where spc.std_products_ID=sp.std_products_ID and spc.std_customers_ID=15) as customer_price, (select top 1 core_pricingfrom std_products_customers spc where spc.std_products_ID=sp.std_products_ID and spc.std_customers_ID=15) as core_pricing, (select top 1 repair_pricingfrom std_products_customers spc where spc.std_products_ID=sp.std_products_ID and spc.std_customers_ID=15) as repair_pricingfrom std_products sp where sp.std_products_ID > 90350Is there a more efficient way to handle this?Thank you for any help |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-08-01 : 16:30:35
|
Since I don't know your DDL, this might be wrong, If so, change LEFT JOIN to RIGHT JOIN and try again.Select sp.part_description, spc.customer_price spc.core_pricing spc.repair_pricingfrom std_products spleft join std_products_customers spc on spc.std_products_ID = sp.std_products_IDwhere sp.std_products_ID > 90350 and (spc.std_customers_ID = 15 or spc.std_customers_ID is null) Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|