SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Other SQL Server 2012 Topics
 Help again
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

IEyeScream
Starting Member

Philippines
6 Posts

Posted - 05/22/2013 :  06:11:40  Show Profile  Reply with Quote
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 https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-frc3/261607_4470109405442_2069214335_n.jpg " target="_blank"> https://fbcdn-sphotos-b-a.akamaihd.net/hphotos-ak-frc3/261607_4470109405442_2069214335_n.jpg

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 05/22/2013 :  06:17:53  Show Profile  Reply with Quote
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

Philippines
6 Posts

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

bandi
Flowing Fount of Yak Knowledge

India
2210 Posts

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

--
Chandu
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2210 Posts

Posted - 05/22/2013 :  06:45:44  Show Profile  Reply with Quote
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

Philippines
6 Posts

Posted - 05/22/2013 :  19:26:01  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 05/23/2013 :  00:42:57  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
2210 Posts

Posted - 05/24/2013 :  03:27:21  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.07 seconds. Powered By: Snitz Forums 2000