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 |
KilpAr
Yak Posting Veteran
80 Posts |
Posted - 2012-09-20 : 10:19:14
|
I have three tables, one named PriceList with fields catalogID, productCode and price like this:catalogID productCode price1 A 11 B 21 C 31 D 42 A 52 B 62 C 72 D 8Another named Catalogs with fields catalogID and taxMultiplier like thiscatalogID taxMultiplier1 1.172 1And one more, TaxAppliesTo with one column, productCode like thisproductCodeACI need now to return productCode and price from PriceList where catalogID = 1 with correct prices so the result is like this:productCode priceA 1.17B 2C 3.34D 4I can't seem to solve this "convert and multiply"-part.I have something like thisSELECT PriceList.catalogID, PriceList.productCode, PriceList.price * TaxAppliesTo.productCodeFROM PriceList,Catalogs,TaxAppliesToWHERE catalogID=1LEFT OUTER JOIN PriceList ON PriceList.productCode = TaxAppliesTo.productCodeINNER JOIN Catalogs.catalogID = PriceList.catalogID Do I need some kind of Case-When-Then? |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2012-09-20 : 11:40:01
|
The code is mixing old style and new style FROM clause syntax, which is not allowed. Try to (inner) join the three tables using only the new style joins and see what data you have. I think you'll see that you have the data elements necessary to derive the results you want returned. Next, use the WHERE clase to eliminate the records you don't want.HTH=================================================We are far more concerned about the desecration of the flag than we are about the desecration of our land. -Wendell Berry |
 |
|
|
|
|