SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Need all activity by product code even if it's empty.


Need all activity by product code even if it's empty.

Author
Message
rlindstrom 38273
rlindstrom 38273
Grasshopper
Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)Grasshopper (24 reputation)

Group: General Forum Members
Points: 24 Visits: 18
I also included the select query that works as needed until I use the WHERE clause with dates. Excuse my ignorance but not sure what else you mean.
LinksUp
LinksUp
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1018 Visits: 4438
rlindstrom 38273 (11/6/2013)
I also included the select query that works as needed until I use the WHERE clause with dates. Excuse my ignorance but not sure what else you mean.


Click on the link under my signature line on the correct way to post questions. That article will explain DDL, Insert Statements, etc . . .

__________________________________________________________________________________________________________
How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/
SteveEClarke
SteveEClarke
Old Hand
Old Hand (371 reputation)Old Hand (371 reputation)Old Hand (371 reputation)Old Hand (371 reputation)Old Hand (371 reputation)Old Hand (371 reputation)Old Hand (371 reputation)Old Hand (371 reputation)

Group: General Forum Members
Points: 371 Visits: 457
Hi -
I think I am right in saying that you are trying to display the Product Class and Months of sales - but you may not have sales in that period - so wish to show a ZERO.

You may require to create a Year/Month Reference Table with the product class - using this as the LEFT table - Join to the details table

Select ProductClass, Year, Month, SUM( ProductClass_SalesValue )
from DateProductClassTable as aa
Left outer join ProductClassDetails as bb
on aa.productClass = bb.productClass
group by ProductClass, Year, Month

Does this help or understand the problem ?

________________________________________________________________________________________________
Regards
Steve
SQL 2008 DBA/DBD - MCTS/MCITP

Please don't trust me, test the solutions I give you before using them.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search