Sum for Trend
-
Hi All, I have a report in which, I have to show the trend values like sum for the same columns I have to show yesterday, 1week ago and 2weeks ago and 1month ago. Like for example I have 2 columns and one date column. Now I have to write a query in such a way that the sum(col1), sum(col2) for 1 day ago, 1 week ago and 1month ago in the same row. Can anybody please help me in writing this query. Any link or any code snippet will be very much helpfull. Thanks in advance.
Thanks & Regards, Md. Abdul Aleem NIIT technologies
-
Hi All, I have a report in which, I have to show the trend values like sum for the same columns I have to show yesterday, 1week ago and 2weeks ago and 1month ago. Like for example I have 2 columns and one date column. Now I have to write a query in such a way that the sum(col1), sum(col2) for 1 day ago, 1 week ago and 1month ago in the same row. Can anybody please help me in writing this query. Any link or any code snippet will be very much helpfull. Thanks in advance.
Thanks & Regards, Md. Abdul Aleem NIIT technologies
Break it into 4 queries, 1 for each time period doing the appropriate aggregation for each query, include the common key. Then join the 4 queries into 1 using the common key. I would use table vars to hold the temp data. BTW I would not put my company name in your sig, it can be incorrectly construed (look it up).
Never underestimate the power of human stupidity RAH