Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 30th, 2006, 07:50 AM
Registered User
 
Join Date: Dec 2006
Location: , , United Kingdom.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Query Problem

I am extracting data from an access DB using vb6. I am trying to extract the last 5 transactions for every account a customer has. I can extract every transaction for every account a user has but need to cut it down. I am having to run two queries just now as transactions are held in two different tables i.e. current year and archived transactions. I have to run it on the archived one as some customers havent made 5 transactions in the one year for all their accounts. Can I combine them and extract the last 5 or do I have to keep them seperate.

The queries I have are -
(Current Transactions)

INSERT INTO `Transactions` (credit_union_id, customer_id, account_id, transaction_detail, `timestamp`, amount) SELECT Account.credit_union_id, Account.customer_id, Account.account_id, Trantype_ID.tranname, Membertrans.Trandate, Membertrans.Tranvalue1 FROM Trantype_ID, Membertrans, Account WHERE Trantype_ID.trantype = Membertrans.Trantype AND Membertrans.Memberno = Account.customer_id AND Membertrans.Account = Account.account_id

(Archived Transations)

INSERT INTO Transactions(credit_union_id, customer_id, account_id, transaction_detail, `timestamp`, amount) SELECT Account.credit_union_id, Account.customer_id, Account.account_id, Trantype_ID.tranname, Memberalltrans.Trandate, Memberalltrans.Tranvalue1 FROM Memberalltrans, Account, Trantype_ID WHERE Memberalltrans.Account = Account.account_id AND Memberalltrans.Memberno = Account.customer_id AND Memberalltrans.Trantype = Trantype_ID.trantype

Would appreciate some help in reducing the transactions to 5.
Transactions are timestamped.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query Problem. rupen Access 3 April 27th, 2007 07:43 AM
query problem purnendu2311 Other Programming Languages 2 December 1st, 2006 02:53 PM
problem with query harpua Classic ASP Databases 1 January 24th, 2005 12:36 PM
Problem in query leo_vinay Classic ASP Databases 5 January 21st, 2005 06:32 AM
query problem mateenmohd SQL Server 2000 7 September 9th, 2003 11:58 PM



All times are GMT -4. The time now is 03:53 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.