July 28, 2013 at 1:07 pm
can some give me hint i am trying to get a statement that will perform a daily sum aggregation on the field cost. It must only use costs that are associated with the follow items: Z001, Z002. The cost must also only come from division
this what I have tried :
DECLARE @dailycost date
SELECT @dailycost = GETDATE()
if @dailycost = @dailycost
SELECT SUM(Cost)
FROM dbo.Cost
where Item = 'ZOO1'
July 28, 2013 at 1:48 pm
How about some DDL for the tables, some sample data and desired output?
Please read the first link in my signature on how to post questions on forums. It will get you answers that much faster.
Good luck.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
July 28, 2013 at 6:55 pm
Duplicate post. All answers here please: http://www.sqlservercentral.com/Forums/Topic1478385-392-1.aspx
My thought question: Have you ever been told that your query runs too fast?
My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.
Need to UNPIVOT? Why not CROSS APPLY VALUES instead?[/url]
Since random numbers are too important to be left to chance, let's generate some![/url]
Learn to understand recursive CTEs by example.[/url]
[url url=http://www.sqlservercentral.com/articles/St
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply