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 |
|
mdixon44
Starting Member
26 Posts |
Posted - 2008-05-06 : 23:38:06
|
| I am very new to SQL and I have a question about inner joins. By using a lookup table and a row function, I have the following question and code. I am not sure if it right or not. I would appreciate any assistance:For every type of food in the l_foods table, list the following:The full name of the supplier from the l_suppliers table. The description of food from the l_foods table The price from the l_foods table plus the price_increase from the l_foods table; rename it to total_priceWhen price increase is null, assume that the 10 cents will be added to the price. Sort this information ty the total price. SELECT a.supplier_name, b.description, b.price_increase AS total_priceFROM l_suppliers AS a, l_foods AS b;Orange- l_foods tableBlue - l_supplier tableRed - within both tables.That is far as I got without error. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-06 : 23:42:32
|
| You need to have some kind of linking relation b/w two tables and join them based on that. Can you please post your table structures? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-07 : 00:31:42
|
| [code]SELECT a.supplier_name, b.description, b.price + isnull(b.price_increase,10) AS total_priceFROM l_suppliers AS aINNER JOIN l_foods AS bON b.supplier =a.supplier ORDER BY total_price[/code] |
 |
|
|
|
|
|