Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to build this query

Status
Not open for further replies.

andypower

Programmer
Aug 10, 2004
23
0
0
IN
hello my self avi. i m developing one bank application in vb 6 and ms access and ado
i have one table Receiptvoucher. fileds r as follows
Transid - double - primary key
Name string
ReceiptDate Date
Amount Currency

suppose Mr. Amir has saving A/c in bank. and he deposit daily [minimum]atleast 100 Rs. in his A/C then that entry is saved in this table. so there are lots of entries of mr. Amir in this table.
so if i give start date as 05/01/2004 and end date as 10/11/2004 then i want to find out the month wise sum of amount of Mr. Amir i.e how much amount he deposited in january from date 05 to 31 , how much in feb[complete feb] same for march,april.......and how much he deposited in 11 th month i.e november up to date 10.
i.e in short if i give start date and end date ,how could i find out the month wise total [only those months should be included that comes in provided date]

plz give me some suggetion on this problem. actually i want this in only one query then it may be nested or sub query or any other. i want to avoid loops. but if not possible give me suggetion in loop also
 
How about something like:
Code:
SELECT NAME, MONTH(RECEIPTDATE) AS MONTHS, SUM(AMOUNT) AS TOTALS
FROM TABLE1 
WHERE RECEIPTDATE BETWEEN <DATE1> AND <DATE2>
GROUP BY NAME, MONTH(RECEIPTDATE)

Hope this helps

Harleyquinn

---------------------------------
For tsunami relief donations
 
First please read faq222-2244. I notice that you have asked more than a dozen questions and haven't acknowledged any of the answers or marked any of them as being helpful. If the answers don't solve your problem, then the faq will help you clarify your question. If they are helpful the faq will give guidance on acknowledging the answers given.

For this one just look up the Shape command in the ADO help section of your MSDN Help

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top