Row_number query - need help ASAP

Hi ,
Need some help bout query
I need a query for display output like below
DATE          CODE     MAC_NO BATCH_NO
01-OCT-07     1119     02     1
20-OCT-07     1210     01     2
01-NOV-07     1209     01     3
01-NOV-07     1510     01     4
01-NOV-07     4025     01     5
01-NOV-07     4025     01     5
01-NOV-07     4051     03     6
02-NOV-07     1209     01     7
i hv no idea how to do it. My query doesn't work for tat requirement.Tis is my query
SELECT date
,code
,mac_no
,ROW_NUMBER()
OVER (PARTITION by date,code,mac_no
ORDER by date,code,mac_no)
as batch_no
FROM PAYMENT
WHERE npcs_cycle_num = 27
AND txn_insert_seq_num > 0;
The output juz like below.I need everybody help ASAP.
DATE          CODE     MAC_NO BATCH_NO
01-OCT-07     1119     02     1
20-OCT-07     1210     01     1
01-NOV-07     1209     01     1
01-NOV-07     1510     01     1
01-NOV-07     4025     01     1
01-NOV-07     4025     01     2
01-NOV-07     4051     03     1
02-NOV-07     1209     01     1
Thanks
CT

I'm sorry..Maybe my words it not that clear enough. You were right about how ROW_NUMBER works (it
assigns a numeric value and resets based on the grouping you specify in the PARTITION clause).
What I want actually is the row number increment based on the txn_date,poc_code and machine_no.
I'm not sure whether using the row_number() can solve my solutions. I really hope that you could help me.
I thought of using row_number() may help. Do you have any other solution?
Here is my table description.
DESC PAYMENT;
Name Null? Type
TXN_ID_NUM NOT NULL NUMBER(12)
ACCT_NO NOT NULL VARCHAR2(14)
CANCEL_CODE VARCHAR2(5)
ADJ_TYPE_NO VARCHAR2(2)
REASON_CODE VARCHAR2(5)
CASHIER_ID_NO VARCHAR2(10)
SUPERVISOR_ID_NO VARCHAR2(10)
REV_CODE VARCHAR2(5)
TXN_DATE DATE
PAY_ADJ_DATE DATE
POC_CODE VARCHAR2(10)
MACHINE_NO VARCHAR2(3)
PAY_MODE_CODE VARCHAR2(5)
ORIG_ACCT_NO VARCHAR2(14)
PAY_AMT NUMBER(12,2)
INVOICE_NO VARCHAR2(20)
PAY_RECEIPT_NO VARCHAR2(24)
PAY_BATCH_NO VARCHAR2(20)
NPCS_CYCLE_NUM NUMBER(4)
TXN_INSERT_SEQ_NUM NOT NULL NUMBER(12)
2) Below is the query before assigning the row number:
SQL> SELECT TXN_DATE,POC_CODE,MACHINE_NO,PAY_BATCH_NO,PAY_AMT,REV_CODE,ADJ_TYPE_NO,PAY_MODE_CODE
2 FROM PAYMENT
3 WHERE NPCS_CYCLE_NUM=27
4 AND REV_CODE IN (SELECT rev_code
5 FROM OUTBND_REV_CODE
6 WHERE outbnd_agen_file_code = 'TMB'
7 AND sys_appl_id ='CCC')
8 ORDER BY TXN_DATE,POC_CODE,MACHINE_NO;
TXN_DATE POC_CODE MAC PAY_BATCH_NO PAY_AMT REV_C AD PAY_M
01-OCT-07 1119 02 20071101120900000000 154.25 017 85 1
20-OCT-07 1210 01 20071101402501400000 444.02 017 00 5
01-NOV-07 1209 01 20071101120901100000 585.32 017 85 1
01-NOV-07 1510 01 20071101402501100000 493 014 00 1
01-NOV-07 4025 01 20071101402501100000 203.85 016 00 3     
01-NOV-07 4025 01 20071101402501100000 487.96 017 00 1
01-NOV-07 4051 03 20071101402501100000 109.26 016 00 3
02-NOV-07 1209 01 20071102120900000000 105.76 014 00 1
3)This is my query and the result:
SQL> SELECT /* SQL_ID 2703 */
2 txn_date
3 ,poc_code
4 ,machine_no
5 ,pay_batch_no
6 ,pay_amt
7 ,rev_code
8 ,adj_type_no
9 ,pay_mode_code
10 ,ROW_NUMBER()
11 OVER (PARTITION by txn_date,poc_code,machine_no
12 ORDER by txn_date,poc_code,machine_no)
13 as row_number
14 FROM PAYMENT
15 WHERE npcs_cycle_num = 27
16 AND txn_insert_seq_num > 0
17 AND rev_code IN (SELECT rev_code
18 FROM OUTBND_REV_CODE
19 WHERE outbnd_agen_file_code = 'TMB'
20 AND sys_appl_id ='CCC');
TXN_DATE POC_CODE MAC PAY_BATCH_NO PAY_AMT REV_C AD PAY_M ROW_NUMBER
01-OCT-07 1119 02 20071101120900000000 154.25 017 85 1 1 (1)
20-OCT-07 1210 01 20071101402501400000 444.02 017 00 5 1 (2)
01-NOV-07 1209 01 20071101120901100000 585.32 017 85 1 1 (3)
01-NOV-07 1510 01 20071101402501100000 493 014 00 1 1 (4)
01-NOV-07 4025 01 20071101402501100000 203.85 016 00 3 1 (5)
01-NOV-07 4025 01 20071101402501100000 487.96 017 00 1 2 (5)
01-NOV-07 4051 03 20071101402501100000 109.26 016 00 3 1 (6)
02-NOV-07 1209 01 20071102120900000000 105.76 014 00 1 1 (7)
8 rows selected.
What I want actually as in the bracket (group by three fields which are txn_date,poc_code and machine_no)
.I hope this is clearer.

Similar Messages

  • Heterogeneous Query, need help ASAP!

    Post Author: zen69
    CA Forum: Data Connectivity and SQL
    Hi all! I'm trying to make a report that uses a view with linked table (tables from a linked server).I tested my view in  SQL Server and it's working but when I try to use it in my report I get these two error messages:Error #1:     Failed to retrieve data from the databaseError #2:   
    Failed to retrieve data from the database.    Details:
    42000:[Microsoft][ODBC SQL Server Driver][SQL Server]Heterogeneous queries
    require the ANSI_NULLS and ANSI_WARNINGS options to be set for the
    connection. This ensures cosistent query semantics. Enable these options and
    then reissue your query. [Database Vendor Code: 7405 ]I'm using
    Crystal Reports CR Professional; Product Type: FullVersion : 11.0.0.895. Please help me ASAP, I really need it to be done! Thanks,J.B.

    Post Author: zen69
    CA Forum: Data Connectivity and SQL
    I forgot to say that I'm using MS SQL Server 2005...

  • Stuttering flv playback issue- need help asap

    We need help asap. Have a project is due to deliver today (5/14).
    We have a video to go on a dvd-rom, live action with Motion Graphics behind.
    When output is done thru Projector the Motion Graphics stutter as they scroll.
    Here is more technical info:
    Stuttering flv playback issue:
    Prores 422 timeline 29.97fps 1280x720 output from fcp using current settings.
    Mov file is approx 7gb, plays relatively smooth on a mac pro with no raid.
    Frame by frame analysis shows all frames are present with no jumps tears or skips.
    Tried several output paths, programs and settings to create a smooth flv file to no avail.
    We adjusted data rates from 2k, 3.5k, 4k and 8k, no luck
    We adjusted keyframe rates from low to all frames, no luck.
    We tried cs3 flash encoder, cs5 media encoder, squeeze ect, same results.
    Playback in the flash projector seems to choke slightly no matter what we do.
    Have also posted in the Director Forum.
    Any help much appreciated!

    Here are a few ideas off the top of my head:
    Try playing the file using a different xtra, sometimes different ones will work better.  If you have Director 11.5, there is a native flv playback xtra.
    You can build a player easily in Flash using the flvPlayback component, then bring that into Director as a swf.
    Once you have the video in Director, try making the member Direct To Stage (DTS).  If it is already DTS, try making it not DTS.
    Make sure the video is not transparent, and nothing in Director overlaps the video... in fact, when the video is playing, nothing should be moving at all, and try to keep the amount of code that is running to a minimum.
    Try lowering your video's data rate further or try using a different codec.
    Using VBR (Variable Bit Rate) compression often makes the video appear to play smoother.
    Try compressing the flv with different software.  FFMpeg, for example, is free and does a very good job, often better than the Flash Video Encoder that comes with Flash/Creative Suite.

  • Need Help ASAP  my State tax form is in a PDF file and the attachment in my email says Please wait

    Need Help ASAP  my State tax form is in a PDF file and the attachment in my email says Please wait...
    I tried downloading updates like it said to but it still will not display the document.  How do I print the PDF file ASAP

    Can you give us a LOT more info?
    What email client? What version of Reader (I can only assume you even have Reader at this point)?
    Please wait? I'm sure it says more than that, right?
    Have you tried simply saving the PDF (it IS a PDF correct?) to your desktop and opening it from there?
    Did you get this form from the IRS or did it come from somewhere else? If the IRS again, what version of Reader?
    Help us help you.

  • How do I reorder songs in a playlist in the new itunes??? I can no longer just click and drag. When I click, it doesn't move!!!! Need help ASAP- trying to prepare for an aerobics class and need songs in a specific order!

    How do I reorder songs in a playlist in the new itunes??? I can no longer just click and drag. When I click, it doesn't move!!!! Need help ASAP- trying to prepare for an aerobics class and need songs in a specific order!

    Vera,
    Use View > View Options, and set 'Sort By" to "Manual Order."
    Then you will be able to drag-n-drop songs up and down the list.

  • My ipod says i have no music on it, but when i plug it into itunes, and look under music on my ipod, its all there. NEED HELP ASAP!!!!! all the music came from a computer which i no longer have, so my ipod is the only place where that music is.

    This morning, i downloaded about 16 songs to put on my ipod, and i manually dragged them over to my ipod to sync that way (like i always do because the music on my ipod came from a different computer which I no longer have) and on my way to work, i realized my ipod says "no content" under Music. However, when I plug my ipod into itunes and click on the music tab under my ipod name, all of my music is there. What happened and how do i get that music back on my ipod? I need help asap.

    You had a glitch and the music files got corrupted. I know of no way to uncorrupt them.
    You can try using a computer app like iFunbox
    http://dl.i-funbox.com/
    to see if yo can get them from the iPod in a usable file.
    Otherwise you will have to re import them to your computer and sync
    You can redownload most iTunes purchases by:                         
    Downloading past purchases from the App Store, iBookstore, and iTunes Store        

  • I restored my iphone and updated it but the progress didn't complete and now my iphone is not working. i need help asap.

    my phone was not working only the restore button was available so i restored it and they told me i have to update my iphone 5s as well. i waited till the end the update software was downloaded successfully but then the iphone restarted by itself and now its not working. the iphone screen is shown the picture when you first time open the phone to connect it to an itunes. i connected it by it not working, i restart everything still not working:( i need help asap please. thankyou

    it seems like apple's activation servers have gone down under the weight of the overwhelming amount of activation requests. you will be able to activate your phone once the servers are able to catch up with the activation requests.

  • My pages document wont open NEED HELP ASAP

    when I go to open a pages document on my mac book pro, the document I'm trying to open is pale and i can't open it. I NEED HELP ASAP.

    How did you install Pages & what version? What model of Mac are you using & what version of OS X?
    The answers to those questions will help anyone trying to answer.

  • Need Help ASAP. Deleting Underline in Adobe Reader Touch.

    I don't understand why it won't let me delete the strikeout or underline in my Adobe Reader Touch. There is no clear option when I highlight it and write click and the "Ctrl-delete" option is not working either. I need to get rid of both of these. Did them by mistake....simple task but so frustrated that I have spent 30+ minutes trying to figure this out. Please help.

    thank you
    ส่งจาก จดหมายของ Windows
    จาก: ambersenos
    ส่งเมื่อ: อา. 11 มกราคม 2558 21:23
    ถึง: thang dinhvan
    Need Help ASAP. Deleting Underline in Adobe Reader Touch.
    created by ambersenos in Adobe Reader Touch for Windows 8 - View the full discussion 
    I don't understand why it won't let me delete the strikeout or underline in my Adobe Reader Touch. There is no clear option when I highlight it and write click and the "Ctrl-delete" option is not working either. I need to get rid of both of these. Did them by mistake....simple task but so frustrated that I have spent 30+ minutes trying to figure this out. Please help.
    If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/7085957#7085957 and clicking ‘Correct’ below the answer
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
    Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/7085957#7085957
    To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"
    Start a new discussion in Adobe Reader Touch for Windows 8 by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.

  • Objects outside of workspace show in SWF... Need help ASAP!

    When I export a flash movie (.swf file)And play it on full screen, the objects that are outside of the workspace show. Can anyone tell me how to fish this problem? need help ASAP! Thanks :]

    If what follows isn't sufficient for you to figure out, you'll have to spend some time learning how to work with Flash.  While you'll often get help solving problems in these forums, it's less likely you will get tutoring services.  Google is a very good resource for tutorials.
    To create a mask you draw a shape to the size you want and place it on a layer above all the content you want to mask.  A mask is actually not well named because masks normally hide things, while in the graphics world, masks define the are where things are shown... so when you apply a mask to something, only what is under the mask shows.  To finalize, you right click on the label area of the mask's layer and select Mask from the menu that appears.  You may have to drag lower layers up towards the mask layer to get them included, whicxh is why I mentioned creating the rest of the content as a movieclip (a single layer object).
    To control the visibility of objects you set their visibility to true or false (AS2: mcName._visible = true (or false),  AS3:mcName.visible = true (or false)).
    To create a frame around the stage, add a new layer atop everything and draw a rectangle big enough to hide all the content you don't want showing that is off the stage.  Then draw a rectangle that is the same size as the stage on top of that first rectangle, placing it over the stage, and then deselect anything that is selected.  Then reselect the smaller rectangle you just drew and delete it.  The larger rectangle is now framing your stage.

  • Error when extracting data with extractor 2lis_04_matnr - NEED HELP ASAP !!

    Hi experts!
    Got an error when extracting data with extractor 2lis_04_matnr.
    System says (short dump):
    DUMP TEXT START----
    Runtime error:    CONNE_IMPORT_WRONG_COMP_TYPE
    Exception:   CX_SY_IMPORT_MISMATCH_ERROR
    Error when attempting to import object "MC04P_0MAT_TAB".
    The current ABAP program "SAPLMCEX" had to be terminated because one of the statements could not be executed. This is probably due to an error in the ABAP program. When attempting to import data, it was discovered that the data type of the stored data was not the same as that specified in the program.
    An exception occurred. This exception is dealt with in more detail below. The exception, which is assigned to the class 'CX_SY_IMPORT_MISMATCH_ERROR', was neither caught nor passed along using a RAISING clause, in the procedure  "MCEX_BW_LO_API" "(FUNCTION)".                                                                             
    Since the caller of the procedure could not have expected this exception      
    to occur, the running program was terminated.                                
    The reason for the exception is:  When importing the object "MC04P_0MAT_TAB", the component no. 5 in the dataset has a different type from the corresponding component of the target object in the program "SAPLMCEX". <b>The data type is "D" in the dataset, but "C" in the program.</b>
    DUMP TEXT END----
    Please, can someone explain me how to solve it? 
    Really need help ASAP!
    Thanks in advance,
    Jaume
    Message was edited by:
            Jaume Saumell
    Message was edited by:
            Jaume Saumell

    Hi,
    Check this note: 328181
    So you need to delete entries in SM13/LBWQ for application and also detup table content.
    And then refill teh set up table.
    If you are in production clear the entries by running collective run no of times for this application 04.
    With rgds,
    Anil Kumar Sharma .P

  • How do you overlap PDF's and finish with one PDF file? Need help ASAP

    how do you overlap PDF's and finish with one PDF file?
    Need help ASAP

    I'm not sure if you can do that with CreatePDF.  Try it; you got one free use when you sign up with Acrobat.com
    If not, you will have to use Adobe Acrobat; there is a full-use 30 days trial.

  • I'm trying to reinstall Logic Pro 9, and it says It's already installed. I have a project due for class and I need help asap. Please help!!!

    I'm trying to reinstall Logic Pro 9, and it says It's already installed. I have a project due for class and I need help asap. Please help!!!

    Yea I am. I deleted Logic Pro 9 and moved the App to the Trashcan like normal. Then when I go to install it, it says its already Installed. When I do this with other apps; it works fine, the install thing comes back up like it should once you have deleted the app

  • User with a paid CC acct, getting "Print.ai" is an unknown format' when trying to open new file. Computer was recently attacked by ransomeware and wonder if I need to re-install Creative cloud software....need help asap!!

    User with a paid CC acct, getting "Print.ai" is an unknown format' when trying to open new file. Computer was recently attacked by ransomeware and wonder if I need to re-install Creative cloud software....need help asap!!

    First, ask in the forum for the program you are using
    This forum is about the Cloud as a delivery process, not about using individual programs
    If you start at the Forums Index https://forums.adobe.com/welcome
    You will be able to select a forum for the specific Adobe product(s) you use
    Click the "down arrow" symbol on the right (where it says All communities) to open the drop down list and scroll
    Second, do a complete scan with a good anti-virus program to be sure your computer is clean... I use Norton, there are others

  • My Curve 9300 lost service need help ASAP

    I lost all serivce on my blackberry curve 9300 and the only way I get service is if I go outside my house. Sometimes I get service in my house but it's for 5 seconds and then I get "searching for network" then it goes to "SOS" I need help ASAP.

    yankeegirl32491 wrote:
    My carrier won't do anything about it because I'm not an authorized user of the account which is stupid. I wasn't having a problem with service for about a year and yesterday my service just cuts out for no apparent reason.
    Hello...well, that's a bit disconcerting...aiding and abetting what could be an unethical use of service...but I'm hopeful that there are further details that mitigate that suspicion. In any event, review this KB for perhaps helpful information:
    KB03448 Network status indicator shows "SOS" on the BlackBerry smartphone
    It is possible that they have a tower out, and you now are receiving service from a more distant tower, which does not have adequate signal strength to work through the walls of your house. But, sadly, there is no way for you to actually find out if such is the case or not.
    Good luck!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

Maybe you are looking for

  • Confirm goods receipt search blank

    Hi All We are on SRM 5.0 SRM Server 5.5. Whenever any user ID selects "Confirm goods / services" or "Confirm goods services centrally" the search always returns no documents. No matter what is entered the result is the same. We have both SC's and dir

  • Secondary exposure correction?

    Is there any way to correct spot exposure problems [ie. clipping] like you can correct secondary color with Three-Way Color Corrector? I have a clip where a white box that reflects too much--it moves, so I need the exposure correction to move as well

  • How to get rid of bugs or trojans off of my mac.

    I believe my computer has been bugged.  Long story short, I got rid of cable, my son wanted to watch football, and without permission tried to download a streaming program.  I trashed the downloaded program and cleaned out the bin but I am afraid it

  • No Print Center

    I just tried to add a new Epson (RX620)printer. I installed the printer software as indicated. When directed to go to applications/utilities/print center to select this printer - no print center app can be found. I cannot add or select a printer from

  • Mysql and phpMyAdmin Mountain Lion Install Question..

    Hello i'm new to OSX MT LION SERVER i managed to set up 2 websites on it.. now all i need is the MySQL Setup and help with phpMyAdmin for each hosted site.. anybody can help me to install and run both servces properly on OSX Server? i have no idea wh