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.

 All Forums
 SQL Server 2012 Forums
 Other SQL Server 2012 Topics
 Help again

Author  Topic 

IEyeScream
Starting Member

6 Posts

Posted - 2013-05-22 : 06:11:40
List of products by category including its current price.

SELECT Product.ProdName,Category.CategoryCode
FROM Product
INNER JOIN Category
ON Product.ProdCode = Category.CategoryCode


How can i include the current price..? I'm just noob on sql server.

This is the tables [url] https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-frc3/261607_4470109405442_2069214335_n.jpg [/url]

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-22 : 06:17:53
just add Product.CurrentPrice field also in the select list

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

IEyeScream
Starting Member

6 Posts

Posted - 2013-05-22 : 06:26:27
but my currentprice is in a different table. and i want to include it in.
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-05-22 : 06:42:27
Duplicate thread: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=185490

--
Chandu
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-05-22 : 06:45:44
SELECT Product.ProdName,Category.CategoryCode, sp.CurrentPrice
FROM Product
INNER JOIN Category ON Product.ProdCode = Category.CategoryCode
INNER JOIN SetPrice sp ON sp.ProdCode = Product.ProdCode


--
Chandu
Go to Top of Page

IEyeScream
Starting Member

6 Posts

Posted - 2013-05-22 : 19:26:01
Total sales per order date.

What Query should i use for this.? sales is not in my tables..

https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-frc3/261607_4470109405442_2069214335_n.jpg
quote:
Originally posted by bandi

SELECT Product.ProdName,Category.CategoryCode, sp.CurrentPrice
FROM Product
INNER JOIN Category ON Product.ProdCode = Category.CategoryCode
INNER JOIN SetPrice sp ON sp.ProdCode = Product.ProdCode


--
Chandu

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-23 : 00:42:57
Group on OrderDate field and apply SUM over sales field (either directly or calculate using qty * price etc)

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-05-24 : 03:27:21
quote:
Originally posted by IEyeScream

Total sales per order date.

What Query should i use for this.? sales is not in my tables..

https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-frc3/261607_4470109405442_2069214335_n.jpg

SELECT O.OrderDate, SUM(sp.CurrentPrice*Od.Quantity) TotalSalesPerDate
FROM Order O
INNER JOIN OrderDetails OD ON OD.OrderCode = O.OrderCode
INNER JOIN SetPrice sp ON sp.SetPriceCode = PD.SetPriceCode
WHERE IsCurrent = true -- true value based on your datatype.
GROUP BY O.OrderDate

--
Chandu
Go to Top of Page
   

- Advertisement -