Select last 3 transactions

pts.
Tags:
Data analysis
Data warehousing applications
Database
DB2
DB2 Universal Database
Development
Oracle
PC/Windows Connectivity
SQL
Hello Can someone help me to put together an SQL statement to select the last 3 transactions from a transaction file. In TransactSQL I would do something like this: select top 3 CustID, TransDate, Amount from Trans where CustID= '12345' order by TransDate desc. I believe there must be a more effcient way of getting the latest 3 transactions. Any help would be greatly appreciated. Suhel.

Answer Wiki

Thanks. We'll let you know when a new response is added.

are you looking for an SQL statement to embed in RPG? COBOL? JAVA? or for some other SQL based interface?

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • BarryCummings
    Suhel: Your own solution looks fine to me. Just make sure that CustID and TransDate are indexed to make the query efficient. Barry
    0 pointsBadges:
    report
  • DB2 DBA
    you can add "FETCH FIRST x ROWS ONLY" and "WITH UR" I beleive that DBq2 V9 has SQL enhancements for this type of query
    40 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following