January 7, 2011 at 9:35 am
Hello,
I have a business requirement which goes as -
'L.E. 2010 Carrier' column = SUM of TEU for all months by tradelane divided by the number of months where data is present multiplied by 12, i.e. if data exists for Jan and February then divide by two and multiply by twelve.
TEU is a column which has all the numeric values and Tradelane contains all the character values.
Another business requirement is-
SUM of all FRT_USD in DHL_TEMP by Tradelane divided by 100.
In this case, FRT_USD is a numeric field in DHL_TEMP table.
Do you have any idea of how to achieve these requirement ? Any small hint would be appreciated.
Kind Regards,
Paul
January 11, 2011 at 8:45 am
I'd do all those calcs in sql server.
Save the base data in temp table.
Then for each group figure out how many months have data.
And do the final cals there to send as little data as possible.
January 11, 2011 at 8:48 am
How to get the # of months from the temp results :
SELECT GroupCol, COUNT(*) FROM (
SELECT Distinct groupCol, MONTH(DateCol) FROM #tmp
) dta
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply