May 5, 2009 at 3:27 am
Hello,
I am looking to write a custom sql server 2005 function that
does the year to date trick for me.
my (simplified) tables look like this:
--------current------------
CarPeriodCostForMonth
BMW10935
Honda20910
BMW10915
--------planned------------
CarmonthCostForMonth
BMW10935
BMW1095
Honda20810
BMW10955
Does any of you have attempted that before and might give
me some advice?
a group by where month = 'P109' gives me the 109's which then have
to be added to the P209's. writing tons of group by's becomes a mess thats why I am looking at a function.
thanks
May 5, 2009 at 7:23 am
What does the data in the month column represent? Does 109 mean January 2009? If it does then I would write something like this:
Select
Car,
Right(month, 2) as year,
Sum(CostForMonth) as ytd_cost
From
current
Group By
Car,
Right(month, 2)
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply