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 |
IEyeScream
Starting Member
6 Posts |
Posted - 2013-05-22 : 02:53:34
|
List of customers including their ordered product and its price per product. Also include subtotal.Click URL to See the Tables [url]https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-frc3/261607_4470109405442_2069214335_n.jpg[/url]
need help for the query please |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-05-22 : 03:31:13
|
--this?
SELECT c.CustomerCode, c.FirstName, sp.ProdCode, SUM(sp.CurrentPrice) PricePerProduct FROM Customer c JOIN Order o ON o.CustomerCode = c.CustomerCode JOIN OrderDetails od ON od.OrderCode = o.OrderCode JOIN SetPrice sp ON sp.SetPriceCode = od.SetPriceCode GROUP BY c.CustomerCode, c.FirstName, sp.ProdCode
-- Chandu |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-22 : 03:44:14
|
Make sure you use LEFT JOIN instead of JOIN in above case if you've Customers who have not ordered yet and still want to retrieve them in your result.
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs |
 |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
|
|
|
|