September 21, 2007 at 9:27 am
Hi
My table data is as below.
YEAR | PERIODID | CONTNBR | Net_Transaction_Amount |
2006 | 6 | 19863 | 249.44 |
2006 | 7 | 19863 | 249.44 |
2006 | 8 | 19863 | 249.44 |
2006 | 9 | 19863 | 249.44 |
2006 | 10 | 19863 | 249.44 |
2006 | 11 | 19863 | 249.44 |
2006 | 12 | 19863 | 249.44 |
2007 | 1 | 19863 | 249.44 |
2007 | 2 | 19863 | 249.44 |
2007 | 3 | 19863 | 249.44 |
2007 | 4 | 19863 | 249.44 |
2007 | 5 | 19863 | 249.16 |
I need the sum of Net_Transaction_Amount below 2007 year and period 3
I am writing the query as below.
SELECT
CONTNBR, SUM(Net_Transaction_Amount) AS UnpaidRecognizeupto2006
FROM
dbo.SVC6040PV
WHERE
(YEAR1 <= 2007 and PERIODID <= 3)
and
CONTNBR
= '0000019178'
GROUP
BY CONTNBR
In the above quiery 2006 year above PERIODID 3 is not considering,
how to calculate sum Below Year 2007 and Period 3, sum should include 2006 year and all periods of 2006 year.
Please let me know, how to do this.
Thx
Vijji
September 21, 2007 at 9:40 am
....where cast(year1 as char(4))+right('00'+cast(periodid as varchar(2)),2)<='200703')
OR
...Where (year1<2007 OR (year1=2007 AND periodid<=3))
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
September 21, 2007 at 10:11 am
Hi Matt Miller
Thank you so much, it is working.
Thx
Vijji
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply