473,466 Members | 1,331 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SUM a range of records from a fixed DATE in the DB

2 New Member
I need to SUM a range of records from a fixed DATE in the DB, the fixed date is 'A.relationship_from' and I have to SUM 90 days from that DATE

SELECT A.AGENT_CODE,T.AGENT_ID,Count (T.TRANS_ACTION_ID), Sum (T.amt_dls),A.relationship_from

FROM TRANSACTION_TABLE T,
AGENT A (NOLOCK)


WHERE T.agent_id = A.agent_id

AND t.DOT >= '2007-05-20'

AND promoter_region = 'SC'
AND promoter_center = '4'
--AND T.AGENT_ID = '460'

GROUP BY T.AGENT_ID,A.agent_CODE,A.relationship_from

ORDER BY T.AGENT_ID

----

This is a result but not from the date I would like :

TX-544 544 2 950.0000 2006-09-26 00:00:00.000
May 23 '07 #1
2 1468
almaz
168 Recognized Expert New Member
Expand|Select|Wrap|Line Numbers
  1. SELECT A.AGENT_CODE,T.AGENT_ID,Count (T.TRANS_ACTION_ID), Sum (T.amt_dls),A.relationship_from
  2.  
  3. FROM       TRANSACTION_TABLE T inner join
  4.            AGENT A (NOLOCK) on T.agent_id = A.agent_id
  5. WHERE
  6.            t.DOT between A.relationship_from and dateadd(dd, 90, A.relationship_from)
  7. AND        promoter_region = 'SC'
  8. AND        promoter_center = '4'
  9. --AND          T.AGENT_ID = '460'
  10.  
  11. GROUP BY T.AGENT_ID,A.agent_CODE,A.relationship_from
  12. ORDER BY T.AGENT_ID
May 24 '07 #2
miguelleugim
2 New Member
It works fine, Thanks !!
May 27 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Sara | last post by:
I have followed instructions on the http://allenbrowne.com/tips.html for limiting a report to a date range. At the bottom there is a note that says You will end up using this form for all sorts...
2
by: chrisale | last post by:
Hi All, I've been racking my brain trying to figure out some sort of Sub-Select mySQL statement that will create a result with multiple rows of averaged values over a years time. What I have...
4
by: norma.j.hildebrand | last post by:
I have a database that has a field (performance standard), every year the standard changed which was not a problem since we start out each year with a blank database and just change the standards...
19
by: ali3n8 | last post by:
Hello I have attempted to create a date range report from a query called qrycustomerinformation. The field that contains the value of my date is called Followup. When i run a report on this it is...
4
by: Bongard | last post by:
I have a dynamic range that I would like to use as a linked table into Access. The problem is that Access doesn't seem to want to to recognize the dynamic range when you click on "show named...
0
by: mwalsh62 | last post by:
Greetings all! My first post here, and my mind is pudding at this point (any flavor you like)! I have been searching for days, and still can't figure out the proper syntax that I require. This...
5
by: jrodcody | last post by:
Hello: I am trying to create multiple records in a table named tblTravel based on the input of a date range in two form controls. The inputs for the form are LastName, TravelDate, EndDate,...
12
by: zandiT | last post by:
hello again i have almost finished with my database. i have decided to generate the reports by using a date or date range and i can't get it to work. first i used parameters in a query but its...
19
by: phill86 | last post by:
Hi I am re-posting this thread because it has become very confusing and I have got some way to solving the problem so it is a slightly different question from the initial thread. here is the...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.