Compare the current value with the previous value in the same column

Hi all,
I have to include a statement in a query which allows to compare the current value of column A with the previous value of column A (same column). from there, I need to add a condition in order to have the expected result.
Let's take an example to illustrate what I want to achieve:
I have the following columns in table called 'Charges':
Ship_id batch_nr Order_nr Price
SID1111 9997 MD5551 50
SID1111 9998 MD5552 50
SID1111 9999 MD5553 50
SID2222 8887 MD6661 80
SID2222 8887 MD6662 80
SID2222 8887 MD6662 80
SID3333 6666 MD7771 90
I want to check if the ship_id of row 2,3 (and more if available) is equal to the ship_id of row 1.
If it is the case, then value 'together with the first batch_nr' in row 2 and 3 under Price column. If not, then keep the original value of Price column
PLease see below the expected result:
Ship_id batch_nr Order_nr Price
SID1111 9997 MD5551 50
SID1111 9998 MD5552 together with 9997
SID1111 9999 MD5553 together with 9997
SID2222 8887 MD6661 80
SID2222 8887 MD6662 together with 8887
SID2222 8887 MD6663 together with 8887
SID3333 6666 MD7771 90
Thanks in advance for your help, it is really urgent.
Imco20030

Hi,
user11961002 wrote:
Hi,
Here is the query that I use:
[ select
sl.ship_id,
o.ordnum,
o.reffld_5 "BatchNR",
sum(tc1.chrg_amt) "FreightPRC",
sum(tc2.chrg_amt) "FuelPRC",
sum (tc1.chrg_amt + tc2.chrg_amt + tc3.chrg_amt) "Total Price"
from ord_line ol
join ord o on (ol.ordnum = o.ordnum and ol.client_id = o.client_id)
join shipment_line sl on (ol.ordnum = sl.ordnum and ol.client_id = sl.client_id and ol.ordlin = sl.ordlin)
join adrmst a2 on (o.rt_adr_id = a2.adr_id)
left join tm_chrg tc1 on (tc1.chargetype = 'FREIGHT' and tc1.chrg_role = 'PRICE' and tc1.ship_id = sl.ship_id)
left join tm_chrg tc2 on (tc2.chargetype = 'FUELSURCHARGE'and tc2.chrg_role = 'PRICE' and tc2.ship_id = sl.ship_id)
where sl.ship_id = 'SID0132408'
group by o.client_id, o.ordnum, o.reffld_2, sl.ship_id, a2.adrnam, a2.adrln1, a2.adrpsz, a2.adrcty, a2.ctry_name,
o.reffld_5, ol.early_shpdte
order by ship_id
]That looks like the query you were using before you started this thread.
Modify it, using the analytic fucntions FIRST_VALUE and LAG, like I showed you.
I see that you did simplify the problem quite a bit, and it's good that you did that.
It doesn't matter that your real problem involves joins or GROUP BY. Analytic functions are calculated on the results after all joins and GROUPS BYs are done. Just substitute your real expressions for the simplified ones.
For example, in your simplified problem, there was a column called order_nr, but I see now that's it's really called o.ordnum. Where the solution I posted earlier says "ORDER BY order_nr", you should say "ORDER BY o.ordnum".
Here's a less obvious example: in your simplifed problem, there was a column called price, but I see now that it's really SUM (tc1.chrg_amt + tc2.chrg_amt + tc3.chrg_amt). Where the solution I posted earlier says "TO_CHAR (price)", you should say "TO_CHAR (SUM (tc1.chrg_amt + tc2.chrg_amt + tc3.chrg_amt))". (You can't use an alias, like "Total Price", in the same SELECT clasue where it is defined.)
I removed some columns from the select as they are not relevant for the wanted action like 'adress details or other references'.
Now here is the result:
Shipment ID     Order Number     WMS Batch     Freight      Fuel Price Order Total Price
SID0132408     MDK-000014-05602649     04641401     110     10 120
SID0132408     MDK-000014-05602651     04641402     110     10 120
SID0132408     MDK-000014-05602652     04641363     110     10 120
as you can see, the 3 orders have the same shipment ID.
The expected result should be shown under column 'Total Price' as follows:
Shipment ID     Order Number     WMS Batch     Freight      Fuel Price Order Total Price
SID0132408     MDK-000014-05602649     04641401     110     10 120
SID0132408     MDK-000014-05602651     04641402     110     10 tog with 04641401
SID0132408     MDK-000014-05602652     04641363     110     10 tog with 04641401Okay, so those are the correct results that I asked for, plus the incorrect results you're getting now. Thanks; extra information doesn't hurt.
But where is the raw data that you're starting with?
It looks like you tried to format the code (but not the results) by typing this 1 character:
before the formatted section and this different character
after the formatted section. To post formatted text on this site, type these 6 characters
before the formatted section, and the exact same 6 characters again after the formatted section.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • How I can stop the combo box with list of values from fireing validations

    Hi I'm using Jdeveloper 11.1.2.3.0
    Using Hr Schema employees table
    I Display employees data in af:table
    and I make List Of values on Department_id filed to easy change the employee department
    and another one on Job_id filed
    and Imake them UI Hints as ( combo box with list of values ) in the employeesVO
    the problem is when I Select a value from department or jobs ( combo box with list of values )
    fires the entire filed validations for mandatory atributes
    Note : the af:table Property ( contedelivery) is set to (immediate )
    How I can stop the combo box with list of values from fireing validations

    check it out.,
    http://andrejusb.blogspot.in/2012/09/what-to-do-when-adf-editable-table.html

  • I want to update iCloud account with new apple id but don't know password for old apple id.  Plus can no longer receive email at old apple id.  How can I delete the current iCloud account on my iPhone if the previously stated conditions exist?

    I want to update iCloud account with new apple id but don't know password for old apple id.  Plus can no longer receive email at old apple id.  How can I delete the current iCloud account on my iPhone if the previously stated conditions exist?

    If the old ID is yours, and if it is an earlier version of your current ID, go to https://appleid.apple.com, click Manage my Apple ID and sign in with your current iCloud ID.  Click edit next to the primary email account, change it back to your old email address and save the change.  Then edit the name of the account to change it back to your old email address.  You can now use your current password to turn off Find My iDevice, even though it prompts you for the password for your old account ID. Then save any photo stream photos that you wish to keep to your camera roll.  When finished go to Settings>iCloud, tap Delete Account and choose Delete from My iDevice when prompted (your iCloud data will still be in iCloud).  Next, go back to https://appleid.apple.com and change your primary email address and iCloud ID name back to the way it was.  Now you can go to Settings>iCloud and sign in with your current iCloud ID and password.

  • Differences between the current base station, and previous gen

    Besides the 802.11n, what are the features that Apple added to the current gen AirPort Extreme Base Station from the 802.11g (UFO style) ones? I ask because I'm looking to replace my router, and being a poor college kid, if the new one doesn't offer enough, I'm just going to get a an older one used.
    I don't particularly need the 802.11n, as I don't have any devices that can take advantage of the technology. Thanks for your help! I hope to give some points soon.
    -Brian

    Time Capsule is the only Apple-supported TM backup to a NAS.
    Time Machine backups to AirDisks (e.g. USB HDD attached to Extreme) is unsupported, but has been successful by some. As well, once you decide to move any old TM backups (HDD connected directly to the Mac) to an AirDisk, you cannot continue backing up to your previous TM backup. The format it saves to vs. a local HDD is different. The folder structure you see becomes a sparsebundle/disk image via the AirDisk.
    If you are interested in proceeding with your plan, check these links out:
    http://discussions.apple.com/thread.jspa?messageID=8225748&#8225748
    http://discussions.apple.com/thread.jspa?messageID=8650723&#8650723
    http://jamesshore.com/Blog/How-to-Accelerate-Time-Machine.html

  • Unable to refresh the schema of FIM MA.Getting an error in Event viewer ""the current version of database is not compatible with the one expected by Forefront Identity Manager service. The current version of database is : 1116. The expected version is :1"

    Hi,
    We have installed FIM MA with an account that have all the sufficient rights.It got created successfully and worked for Full Import and Full Sync. But, due to some version incompatabilities, we have installed a patch.PFB link for the patch.
    http://support.microsoft.com/en-us/kb/2969673/en-us
    Now, we are trying to refresh the schema of FIM MA. While doing that we are facing an error "Failed to connect to database". The user account with which we are connecting has read and write permissions on DB.In the event viewer some errors are
    logged like  "the current version of database is not compatible with the one expected by Forefront Identity Manager service. The current version of database is : 1116. The expected version is :1122" with event ID 3. PFB images for more detailed
    view.
    Please advice how to fix the issue.
    Thanks
    Prasanthi.

    Hello,
    seems to me that you maybe only updated the syncengine but not portal/webservice.
    I had that error once after an recovery from scratch and forgot one of the hotfixes to apply to all services.
    -Peter
    Peter Stapf - ExpertCircle GmbH - My blog:
    JustIDM.wordpress.com

  • My original iPad still shows iOS 5.1.1 as the current version with no opportunity to update.

    My original iPad still shows iOS 5.1.1 as the current version with no opportunity to update.

    No IOS 6 for Original iPad.

  • I'm trying to use my iPad mini for the first time with a previous apple ID and password but it will not connect to iTunes but I can download apps from my iPhone using the same appleID and password and it works on my iphone...PLEASE HELP NOW

    I'm trying to use my iPad mini for the first time with a previous apple ID and password but it says "iTunes is not working try again"...it allowed me to download an app on my iPhone using the same apple ID & password but all my apps are in "Waiting Status" on my iPad mini because it says "iTunes is not working"...PLEASE HELP ME NOW!!!

    Previous user installed iOS 7 beta on that iPhone.
    Take it back and get your money returned. You
    are running into a new security feature. Whoever owns
    the ID that it is asking for is the only person who can
    remove the security. That iPhone is worthless to you.

  • I downloaded CS6 Red Plug-In and added to Package Contents, replaced the current files with the new without backing up, now my RED footage thumbnails and color-correction don't WORK! How do I get my old importerRed file back!!?? HELP!

    I downloaded CS6 Red Plug-In and added to Package Contents, replaced the current files with the new without backing up, now my RED footage thumbnails and color-correction don't WORK! How do I get my old importerRed file back!!?? HELP!

    Try asking in the Premiere Pro  forum seems to be an Adobe Lab for Premiere Pro

  • PowerView Errors in the metadata manager. The current model can only be expressed when the client is requesting tabular view metadata with VERSION restriction of 2.0 or later

    SQL 2012 SP 1 CU4 applied. Now getting " Errors in the metadata manager. The current model can only be expressed when the client is requesting tabular view metadata with VERSION restriction of 2.0 or later"
    Any ideas what could be causing it to send the incorrect version?

    amaltsev1,
    It appears that in the past few days you have not received a response to your
    posting. That concerns us, and has triggered this automated reply.
    Has your problem been resolved? If not, you might try one of the following options:
    - Visit http://support.novell.com and search the knowledgebase and/or check all
    the other self support options and support programs available.
    - You could also try posting your message again. Make sure it is posted in the
    correct newsgroup. (http://forums.novell.com)
    Be sure to read the forum FAQ about what to expect in the way of responses:
    http://forums.novell.com/faq.php
    If this is a reply to a duplicate posting, please ignore and accept our apologies
    and rest assured we will issue a stern reprimand to our posting bot.
    Good luck!
    Your Novell Product Support Forums Team
    http://support.novell.com/forums/

  • Is there any way to to have the "Home" icon open a new tab instead of replacing the current page with the home page?

    I would prefer that the "Home" icon on the Navigation Toolbar open a new tab instead of replacing the current tab with the home page. Is there any way to accomplish this?
    Thank you.

    If you middle-click on the home icon it will open a new tab containing the home page.

  • Will the current iMac with two Thunderbolt ports support up to 12 devices (6 per port) or just 6 total?

    Will the current iMac with two Thunderbolt ports support up to 12 devices (6 per port) or just 6 total?

    If will handle 7 devices total, you will use one thunderbolt port as an upstream and the other as a downstream. 
    Take a look at this link, http://en.wikipedia.org/wiki/Thunderbolt_(interface)

  • Whats the current deal with popup windows in flash?

    Hi There,
    whats the current deal with popup windows in flash? I'm
    trying to include popup windows in a site, and with IE7 (or
    whatever the newest version of IE is ..the firefox lookalike) the
    popups are not working at all, I have gone out a gotten other
    sample popup scripts and I encountering the same problem, which is
    the popups aren't working at all?
    Is this a problem with just IE7 or am i completely missing
    out on something here?
    any ideas would be really appreciated! or if anyone has any
    scripts for sizeable popup windows that work on IE7 i would really
    appreciate it. thanks
    :}

    well i have used a couple of different attempts. I have used
    code generated by this:
    http://www.flash-db.com/PopUp/
    on (release) {
    getURL
    ("javascript:NewWindow=window.open('pants.html','newWin','width=200,height=50,left=0,top= 0,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No');
    void(0);");
    I have also tried a couple of other tutorials from
    http://www.kirupa.com
    link;
    http://www.kirupa.com/kirupa.htm'
    and I used the javascript supplied and had no luck (I
    embedded the html etc) ... i have tried about 5 other tutorials and
    I've got to the point where I'm wondering is the problem based
    around by browser, I only using IE7 and have no ther browser. I'm
    using FlashMX 2004. all the example files .fla and swfs i have
    downloaded aren't working either so I'm totaly scartching my head
    at this point...
    any ideas where i'm going wrong here? any help very much
    appreciated
    :}

  • Enhancing the component ERP_H with a custom field in the web UI

    Hi,
    I'm facing an error when enhancing the component ERP_H with a custom field in the web UI.
    I've followed the steps mentioned in the pdf document called "Enhancement Options for the Lean Order Interface" (Note
    1224179):
    I´ve done a enhacement on ERP_H component.
    I added a field to the view Headerdetail called "ZZCCTYPE1", but when I set a value in UI, I haven´t read this field in abap code.
    The SET method (SET_ZZCCTYPR1) in the context node is ok, in debug I see that the method current->set_property, is working fine.
    I've tried to read the atribute with lr_entity->get_property_as_string ( 'ZZCCTYPR1' ), but doesn´t work. When I read other "standard field", the statement is ok and it has value.
    When I set the value of the field from ECC (VA01/VA02), it is kept by the system.
    Could anybody help me?
    Thanks in advance,
    Regards,
    Andrea Ricci

    Hi Pooja,
    When you created your custom views, did you bind the view context nodes to the corresponding context nodes of your component controller?
    From the exceptions you reported it seems that this binding is missing.
    To create this binding, you can right click on your view context node , choose "Create Binding" and bind it to the context nodes of your Component Controller.
    Hope this helps.
    Regards,
    Nisha

  • Charge sales order value with a minimum value

    Dear All,
    I have one requirement where I would like to charge my sales order value with a minimum value. For example, a minimum sales order value requirements are set at $1,400.00 (the minimum values can be different based on the different materials) per order, if the value of the order exceeds $1,400.00, therefore no minimum fee is applied or displayed and the customer is charged the actual value of the order; if the value of the order is less than the minimum thus the customer is charged the minimum. We also can set the minimum as quantity.
    Is there any standard functionality through which this can be done.. or any suggestion?
    Your help is highly appreciated.
    Thanks and best regards,
    Jo

    You can maintain the Condition Record with Condition Type as AMIW wrt to Division & Price Group.You can change the Accesses as per your requirements.
    Best Regards,
    Ankur

  • Change the current row in an iterator and reflect the change on page

    Hi there,
    I have a jspx with a creation form created as usual draging and droping the data control. In same page, I inserted a commandButton which ActionListener executes a method in a managed bean called validate(). Through such a method what Im trying to do is to fill the form with data from specified entry of the database if certain condition is true. I know it is kinda twisted but unfortunately is the requirement for the page.
    So basically in "validate" method, if the condition I mentioned is reached, I do the following:
    // execute a Rollback (included in Page Definition) in order to cancel the previous auto-invoked "Create".
    FacesContext context = FacesContext.getCurrentInstance();
    Application app = context.getApplication();
    BindingContainer bindings =(BindingContainer)app.getVariableResolver().resolveVariable(context,"bindings");
    OperationBinding opBinding = bindings.getOperationBinding("Rollback");
    opBinding .execute();
    //get the iterator and asociated VO from the binding container
    ValueBinding vb = app.createValueBinding("#{bindings.AccountsVOIterator}");
    DCIteratorBinding dciter = (DCIteratorBinding) vb.getValue(FacesContext.getCurrentInstance());
    ViewObject view = dciter.getViewObject();
    //and set the current row with the specified entry I have mentioned above.
    Object keyValues[] = new Object[2];
    keyValues[0] = "1"; keyValues[1] = "98543";
    Row[] row = view.findByKey(new Key(keyValues),1);
    AccountsVpnVORowImpl client = (AccountsVpnVORowImpl)row[0];
    view.setCurrentRow(client);
    view.executeQuery();
    dciter.setCurrentRowWithKey(client.getKey().toStringFormat(true));
    dciter.executeQuery();
    opBinding = bindings.getOperationBinding("Execute");
    opBinding.execute();
    All this works perfectly when I debbug it but I cannot see the changes in the page(even refreshing browser). I need that when such a condition is met, the creation form turns into a modify-specific entry form, filling all fields with the specific data in order user can modify it, and all in the same page.
    Any clue?
    Thanks so much in advance for your time.

    Hi,
    I could see the problem with call to executeQuery and execute methods at the end of your method which re-sets the current row.
    Once you set the current row you should not call execute or executequery methods. Try removing those calls and also make sure that you have added partialTriggers property on the table is set to commandbutton id and partialSubmit property is set to true on commandButton to refresh the table partially on click of a button
    Sireesha

  • The BPM stops, with a "green flag " in the sxmb_moni enrty

    i have a file to file with a BPM,
    the BPM contains:
    1. a loop which runs five times which contains a receive step with [start transaction] and a using and activating correlation value.
    2. a container step that appneds the messages picked one by one through each iteration of loop into a multiline container.
    3. a send step.
    the purpose is to collect 5 files with a particular correlation value and merge them and send them,
    the problem is, as soon as the file is picked and the message is received at the receive step, the BPM stops, with a "green flag " in the sxmb_moni enrty,
    i cant make out anything from the PE in the moni entry....
    is it some problem with the correlation......help me out...

    yes Raj,
    i have a transformation step ...that transforms the content of the multiline container into a normal container before sending.............
    this is the problem, i can never see the wait symbol, and
    its sometimes strange, some times the process ends with "red flag" on the outbound side (right hand side of the moni entry)...
    i can see the graphical............
    i forgot to mention...all the steps are in a block....
    so in the graphical wf log,  i can see an error at the entry of the block, except that there is no error.....

Maybe you are looking for

  • Attachments via Apple Mail

    I've searched and did'nt find an answer to my problem (hopefully I didn't overlook), so I made a post. Lately, my clients and recipients haven't been able to receive my attachments when I send using the Mail.app. If I send a PDF or a regular JPG file

  • IDOC Mapping with field determination

    Hi All. My requirement for this PI Mapping has the following. A root node (E1IDPU1) has a document name and document number. This also has a child node (E1EDP02) that can occur 5 times and in it a qualifier and belnr that occurs once in each instance

  • No Wifi in Windows

    When I try to connect my wireless apple mouse and keyboard, Bluetooth does not find them. I click add and then next, after that, for a second it says it is searching and then it says it was unable to find any devices. What can I do to fix this so it

  • Printer won't print in Color

    I have a MacBook Air running 10.9.4 running to a Brother 3170CDW printer using the driver found at the link below.  It will not print in color.  I have deleted the driver and reinstalled it, as well as checking for any other brother drivers on the sy

  • Apex Pivot Tables

    Does Apex support pivot tables? I do this all the time in Excel, and it's really easy. If Apex could do this too, I'd consider it fully functional. If it doesn't support pivot tables, that would be an excellent feature to add to Apex 4.0 or 4.1. (I'm