Query to retrieve latest five transactions for each account

hi,
I have a table containing transactions of all account holders (this table contains thousands of records). My requirement is to retrieve recent five transactions from the table for all the account holders. Can anyone help me to retrieve the required data.
Note: Each account holder may have more than one account e.g. savings account, current account etc.
Regards,
N Madhavan

Hi,
try something like
select * from (select row_number() over (partition by holders order by transaction_date desc) r, t.* from t) where r<6;
HTH
Laurent Schneider
OCM DBA

Similar Messages

  • Query to find the latest two transactions for each Group

    Hi All,
    Consider the following sets of records in a table test.
    Group---Tran_Dt---SlNo
    c1 10/10/2003 1
    c1 10/10/2003 2
    c1 10/10/2003 3
    c1 11/10/2003 1
    c2 10/10/2003 1
    c2 10/10/2003 2
    c2 11/10/2003 1
    c2 11/10/2003 2
    c2 11/10/2003 3
    c3 10/10/2003 1
    c3 10/10/2003 2
    c3 10/10/2003 3
    I want to list out the latest two transactions for each group irrespective of the slno and trans_dt as below:
    group tran_dt SlNo
    c1 11/10/2003 1
    c1 10/10/2003 3
    c2 11/10/2003 3
    c2 11/10/2003 2
    c3 10/10/2003 3
    c3 10/10/2003 2
    Any help on this would be appreciated.
    Thanks
    Walter Nicholas T

    Hi Walter,
    Please try following query.
    select Group,tran_dt,sino from
    select Group,tran_dt,sino,(DENSE_RANK()OVER (PARTITION BY Group ORDER BY tran_dt desc,sino desc)) rank from test
    ) where rank between 1 and 2
    Thanks,
    Samir

  • Query to retrieve latest version

    Hi,
    I am trying to create a query that retreives the latetst version of a product. There are 2 tables I query from, one has the product number and one has the version- a varchar2(60) datatype. The versions are listed A,B,C..... etc. So I want the query to give me one row for each product with its latest version. This is the query I have thus far,
    SELECT A0.Prod_num, A0.version
    FROM (SELECT A0B.Prod_num, A0.version
         FROM tb_1 A0,tb_2 A0B
         WHERE (A0.tb_1pk=A0B.tb_2pk)) A0
    order by A0.Prod_num
    This returns duplicate rows of products and versions.
    Thanks.

    sybrand_b wrote:
    SELECT A0B.Prod_num, A0.version
    FROM tb_1 a0, tb_2 A0B
    where a0.tb_1pk = a0b.tb_2pk
    and a0.version =
    (select max(version)
    from tb_1 a0a
    where a0a.tb_1pk = a0.tb_1pk
    Question: This aren't the real table and column names, hopefully, are they?
    They are so cryptic the chance for erroreneous statements is 99.9 percent!
    Sybrand Bakker
    Senior Oracle DBASybrand,
    If you think these names are cryptic, the actual names names are much, much worse. This a COTS application and the datatbase object names, for some reason, are completely random and counter-intuitive.
    Thanks for the query solution!

  • How can i pull the payment transactions for each invoice?

    Hi folks
    iam developing report for following requirement.
    want to disply the vendor transaction file for all company codes Fiscal year,of 2004,2005,2006, and 2007 (to date).
    The purpose of oureport is to analyze our company invoices and investigate potential overpayment opportunities. In order to effectively accomplish this, we need a single invoice record for each invoice that was received by compnay from their vendors. The single invoice record would contain at least the following columns: Vendor Number, Vendor Invoice Number, Invoice Date, Invoice Amount, SAP Document Number, Check/Wire Number, Check/Wire Date, Check/Wire Amount. SAP would have multiple rows in a table for any one invoice, whereas we would only want to see ONE row for every vendor invoice.
    if you know that company pays (for example) 75,000 invoices/year - then the transaction file you would have about 300,000 records in it. 75,000 Invoices * 4 years.
    inodrer to develop this report iam using table PAYR -payee
    BSIK ( closed items) BSAK ( open items).
    my question is any one tell me how can write logic to  pull the payment transactions for each invoice?
    regards
    neeru

    Hi rob,
    yes you are right,  an invovice may contaion duplicate records
    example  PAYR table contain
    invice no         compnay code  checkno vendor  fisclyear
    ( doc.number)
    2000134373     001                    10287200          2007
    2000134373     001                    10427890          2007
    so as per my requirement how can i write the logic.
    regards
    neeru

  • How to get all GL accounts for each account in a given bank...

    Hello Experts,
    Is there a way to get all GL accounts for each account in a given house bank?
    IN our company, there are 5 GL accounts for each bank so 1 GL for 1 account. they are for recon, payables,
    receivables, etc. I checked table T012K but it only shows the main GL account. Hope you
    can help me guys. Thank you and take care!

    Try this.. it is based on company code
    here it_cocodes is an internal table containing company codes
      DATA: BEGIN OF it_glaccount OCCURS 0,
        bukrs TYPE bukrs,
        saknr TYPE saknr,
        txt50 TYPE txt50_skat,
       END OF it_glaccount.
      DATA it_glaccount_wa LIKE it_glaccount.
    LOOP AT it_cocodes INTO it_cocodes_wa WHERE ktopl <> ''.
        SELECT bukrs saknr FROM skb1
          INTO CORRESPONDING FIELDS OF it_glaccount_wa
          WHERE bukrs = it_cocodes_wa-bukrs.
          IF sy-subrc = 0.
            SELECT SINGLE txt50 FROM skat INTO it_glaccount_wa-txt50
              WHERE spras = 'E' AND ktopl = it_cocodes_wa-ktopl
              AND saknr = it_glaccount_wa-saknr.
            APPEND it_glaccount_wa TO it_glaccount.
            CLEAR it_glaccount_wa-txt50.
          ENDIF.
        ENDSELECT.
    loop at it_glaccount into it_glaccount_wa.
    write:/....
    endloop.
    refresh...
    clear...
    endloop.

  • If I have two email accounts, one personal hotmail account and one MS Exchange work account, how can I setup individual notifications for each account. Right now, any email from any account has the same notification. I want work to be different than perso

    If I have two email accounts, one personal hotmail account and one MS Exchange work account on my iPhone 4s, How can I setup individual notifications for each account? Fore example, if I get a work email, I want to hear a DING, DING....If I get a personal email, I want to hear a BEEP, BEEP. Right now, any email from any account has the same notification. I want work incoming email notification to be different than personal incoming notification. The only semi-workaround I've seen is just disable any notification for the Hotmail account, so only work emails would notify. But then I don't know when I get a personal email. Even the lowely Blackberry Torch 9800 has this feature..not iPhone 4s??
    Thanks

    Sorry you get only one notification sound for all email accounts.  you can send a suggestion to apple here http://www.apple.com/feedback/

  • How to Set "delete from hub and server" for each account

    How can I set "delete from hub and server" differently for each account?
    I have 3 emails (2 shared, 1 personal).
    the personal is a 'hotmail' account which has device set to 'sync email', 'push', and 'Use SSL'.
    it will only sync one way (from desktop to device).
    I cannot set the global setting on the device to "delete from Hub and server" without affecting all accounts.
    I do not want to have to confirm delete on every item.
    previous to the 10.3 update this was not an issue.
    am i missing something? or is this another step backwards?

    The only other way would be to set it to prompt every time you get an email. Yeah, I know that defeats the purpose.. I guess in this aspect it is a step back

  • My itunes library has organically grown from more than one itunes account but all now on a separate computer.  If I upgrade to iTunes match will I have to pay for each account?

    My itunes library has organically grown from more than one itunes account (all paid for by me) but all now on a separate computer.  If I upgrade to iTunes match will I have to pay for each account or just once, for the computer?

    No.  Provided the computer that you use to upload / match your Songs is authorised to play all of the Songs all works well - once complete you can download Song files that will play on your libraries / other computers without each computer having to be authorised.

  • Help to configure msoutlook separate inbox for each accounts in office 365 in mac

    i have installed office 365 in mac pro book and configured 3 accounts. all the mails are downloading to same inbox. please let me the configuration to receive mail in separate
    inbox, sent, draft, etc.. for each accounts

    Hi,
    By default, the Outlook folder list groups similar folders, such as inboxes, from all of your mail and Microsoft Exchange accounts. This feature can make it easier to read all your messages at once, without having to move around between mail folders.
    If you want, you can turn off this feature so that each account and all its folders are separated in the folder list:
    http://office.microsoft.com/en-us/mac-outlook-help/show-separate-inboxes-for-each-account-HA102928387.aspx
    Also, this is the forum to discuss questions and feedback for Windows-based Microsoft Office client, better to post your question to the forum of
    Office for Mac:
    http://answers.microsoft.com/en-us/mac/forum/macoffice2011?tab=Threads
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
    Thanks,
    Ethan Hua CHN
    TechNet Community Support

  • Any way possible to have different New Eamil alret sounds for each account

    I have 4 different email accounts on my iPhone. Is there a way to have a different New Email Alert sound for each account. Most of the times I am only interested in emails I get in one or two of the accounts and if I had a different Alert for them I would know right away rather than having to go through each account inbox to find out which one got a new email.

    Not at this time.

  • I'd like Time Machine to backup my personal account's files separately from my guest account's files. Both have big files.  What's the best way to do this?  Should I connect 2 external HD to my new iMac, one for each account?

    I'd like Time Machine to backup my personal account's files separately from my guest account's files. Both have big files.  What's the best way to do this?  Should I connect 2 external HD to my new iMac, one for each account?

    NeuroBrain wrote:
    Since my new external hard drive is have a lot of space, I'm thinking of splitting it for Time Machine and external storage.
    This is a common mistake and I highly advise against it.
    1: TimeMachine saves states of changes and thus requires more room on the TM drive than the boot drive it's backing up.
    2: Something happens to the TM drive, loss, theft, dropped, power surge, etc., you lose both backups.
    3: The storage drive might become a portable need, with it being on the TM drive, now your increasing the risk to the TM backup that something could happen to it along with the storage drive, due to increased movement.
    Seriously, have a read,
    Most commonly used backup methods
    it's ASC User Tip that saves us regulars all the trouble of having to repeat ourselves over and over again in the posts, because we tend to forget things too, or not here sometimes etc.
    "Plan for the worst and the good will take care of itself" - Donald Trump

  • ALWAYS asks for Password for each account... I've tried most everything..?

    Good day.
    At least several times a day my apple mail asks me to enter the p/w for each account. This on both machines.
    I've tried many times to:
    Click the "Save my password in Keychains"
    In prefs I've "entered my password on each account and saved"
    (That always disapears, each time I go back)
    Can you please help with suggestions?
    Thank you much.
    T

    Can you see the login items in Keychain Access (in /Applications/Utilities) and verify that their passwords are set correctly?
    If you navigate into your Library/Preferences folder and select com.apple.mail.plist and do a Get Info, are your permissions set to Read & Write (and Everyone else's permissions set to No Access)?

  • Retrieve first 3 records for each id

    Hi there,
    I am having trouble solving this problem. Appreciate for any help.
    tableA
    pidm
    1125
    0034
    tableB
    pidm     term
    1125     2006
    1125     2007
    1125     2009
    1125     2010
    0034 2004
    0034     2006
    0034     2007
    0034 2008
    I want to retrieve only the first 3 records from tableB order by term for each pidm that match to pidm of tableA
    select pidm, term from tableB where pidm in (select pidm from tableA) and rownum < 4
    This only return 3 records instead of 6:
    it should return:
    pidm:     term:
    1125     2006
    1125     2007
    1125     2009
    0034 2004
    0034     2006
    0034     2007
    Thanks

    sql>select pidm, term
      2    from (select a.pidm, b.term, row_number() over (partition by a.pidm order by b.term) rn
      3            from tablea a, tableb b
      4           where b.pidm = a.pidm)
      5   where rn <= 3;
    PIDM TERM
    0034 2004
    0034 2006
    0034 2007
    1125 2006
    1125 2007
    1125 2009
    6 rows selected.

  • New wmail for each account?

    I have 2 Macs, 1 Macbook Pro, and I plan on purchasing the new iPad2 this weekend. I want to have Facetime on all these devices so I could use it from anywhere, but does that mean I need a separate email address for each device (which would mean I would need 4 email addresses? If not, then would a Facetime callping me at all locations? Does anyone know the answer to this?

    KLansford wrote:
    I have 2 Macs, 1 Macbook Pro, and I plan on purchasing the new iPad2 this weekend. I want to have Facetime on all these devices so I could use it from anywhere, but does that mean I need a separate email address for each device (which would mean I would need 4 email addresses? If not, then would a Facetime callping me at all locations? Does anyone know the answer to this?
    If you want to be able to answer a call on any of the four devices, you must use the same iD on each.
    If you want to be able to call each device individually, or call on from the other, each must have its own.
    EZ Jim
    Mac Pro Quad Core (Early 2009) 2.93Ghz Mac OS X (10.6.6); MacBook Pro (13 inch, Mid 2009) 2.26GHz (10.6.6)
    LED Cinema Display; G4 PowerBook 1.67GHz (10.4.11); iBookSE 366MHz (10.3.9); External iSight; iPod4touch4.2.1

  • How to limit the number of emails that are shown for each account

    Hi, I'm going from iOS 6.1 to my new 5s iOS 7 and I wanted to know if there was a way to limit the number of emails shown for each of my accounts? In iOS 6 there is a setting "show" where you can choose how many you would like to be loaded at a time from 50-1,000 , is there a setting similar to this and I am just not seeing it? Please help me asap. I have only logged in 3 of my 12 email accounts and already have over 13k emails loaded...

    You can't limit it to the last 50 messages, but you can limit it to the last 1000 messages in each "folder" (label).
    Go to the Gmail website and click on the gear icon to the top-right side.
    Click on Settings.
    Click on the "Forwarding and IMAP/POP" tab across the top of the Settings area.
    Towards the bottom of the IMAP section, change the "Folder Size Limit" setting to "Limit IMAP folders to contain no more than this many messages". By default 1000 is selected, though you can also choose 2000, 5000, or 10000.
    Click Save Changes at the bottom.

Maybe you are looking for

  • Centralised Report for Sales/Purchase

    Hi guys, One of my client needs a Centralised report for Sales & Purchase for a particular period . Like we are mainting multiple taxcodes  like BED,eCess,HeCEss, VAT 4,VAT 2,VAT12.5, VAT10.3,TAXEXEMPTED,ETC... So every month they need to know total

  • IPad 2 chooses to use Cellular data instead of Wi-Fi (This is Sh*t!)

    Just learned today, the hard way, that for some reason the iPad 2 in it's eternal wishdom chooses to use Cellular data (3G) over Wi-Fi while both are available! If the iPad 2 is not smart enough or can not be made smart enough to strongly choose Wi-F

  • Virtualized firewall under Hyper-V?

    We are currently considering installing an instance of pfSense on our Hyper-V R2 based server to act as a content filter, captive portal and general firewall. Although it is usually bad practice to virtualise a firewall / gateway.. sometimes you gott

  • Weak BT on Pro

    I recently reorganized my office and, for the first time, I am experiencing BT range issues. My MM and keyboard are about 4-5 feet from the tower. This issue was addressed in the discussions a year or so ago. Switching antenna wires was the recommend

  • IChat video quality inherantly suffers when over wireless EVDO aircard?

    I am just guessing. Is this true? Or just in our case? Our being myself and my girlfriend, who is the one with a cam. I am new to iChat but I am not receiving that 'full screen, perfect quality' image that I thought iChat was supposed to have. You se