July 4, 2011 at 7:19 am
Hi frd's,
Here the tables
In table t1
columns : sys_id (char)= abc , abc
product_code (char)=Reatail , wholesale
last_modified (date_field)=2011-04-20 00:03:35.247 , 2011-04-20 00:03:35.247
deal_id : sg123 , sg124
In table t2
Columns:gl_balance -54644.2400 , 2070495.0000
deal_id : sg123 , sg 124
Now my requirement is :
The data is grouped by Sys_ID and Product_Code to calculate, Find the sum of GL_Balance for respective Reporting date & previous Reporting date. Then find the cumulative value of the Gross GL Balance in between the current reporting day and the previous reporting dayMy code is like this
nw i need is sum of GL_Balance for respective Reporting date & previous Reporting date
I codded like this:
SELECT t1.Sys_ID,t1.Product_Code,
DATEADD(s,0,DATEADD(dd, DATEDIFF(d,0,getdate()),0)) As Current_reporting_Period,
SUM(t2.gl_balance) AS CurrentGL_Balance,
DATEADD(s,0,DATEADD(dd, DATEDIFF(d,0,getdate()-1),0)) As Previous_reporting_Period,
SUM(t2.gl_balance) AS PreviousGL_Balance
FROM t1
INNER JOIN t2
ON t1.deal_id=t2.deal_id
GROUP BY t1.sys_id,t1.product_code,t1.last_modified
adv tkq,
July 4, 2011 at 10:50 am
duplicate post.
original post including a number of replies.
@bhargava
Please don't cross post. Instead of open yet another thread with the very same question it would have been better to provide the data some of us asked you for.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply