Order By Two Different Fields

Dear All,
I have a Table Like this,
CREATE TABLE test_d (c_id VARCHAR2(10),i_no NUMBER,i_date DATE)
which contains the data as,
C_ID     I_NO     I_DATE
1     2     19-Jan-2007
1     3     19-Dec-2006
1     4     19-Nov-2006
1     5     19-Oct-2006
1     6     19-Sep-2006
1     1     19-Feb-2007
2     6     19-Feb-2007
2     5     19-Jan-2007
2     4     19-Dec-2006
2     3     19-Nov-2006
2     2     19-Oct-2006
2     1     19-Sep-2006
Now, I want to write a Sql to find the records,for which i_no "1" i_date is greater than i_no "2" i_Date and respectively.

SQL> select * from test_d
  2  /
C_ID             I_NO I_DATE
1                   2 19-01-2007 00:00:00
1                   3 19-12-2006 00:00:00
1                   4 19-11-2006 00:00:00
1                   5 19-10-2006 00:00:00
1                   6 19-09-2006 00:00:00
1                   1 19-02-2007 00:00:00
2                   6 19-02-2007 00:00:00
2                   5 19-01-2007 00:00:00
2                   4 19-12-2006 00:00:00
2                   3 19-11-2006 00:00:00
2                   2 19-10-2006 00:00:00
2                   1 19-09-2006 00:00:00
12 rijen zijn geselecteerd.
SQL> select c_id
  2       , i_no
  3       , i_date
  4    from ( select test_d.*
  5                , max(i_date) over (partition by i_no) max_i_date
  6                , min(i_date) over (partition by i_no) min_i_date
  7             from test_d
  8         )
  9   where max_i_date > min_i_date
10     and (  (   c_id = 1
11            and i_date = max_i_date
12            )
13         or (   c_id = 2
14            and i_date = min_i_date
15            )
16         )
17   order by i_no
18       , c_id
19  /
C_ID             I_NO I_DATE
1                   1 19-02-2007 00:00:00
2                   1 19-09-2006 00:00:00
1                   2 19-01-2007 00:00:00
2                   2 19-10-2006 00:00:00
1                   3 19-12-2006 00:00:00
2                   3 19-11-2006 00:00:00
6 rijen zijn geselecteerd.Regards,
Rob.

Similar Messages

  • Dataload - Evaluate two different fields

    Hi, I need to evaluate two different fields in a dataload rule and apply condition if true. for instance if field 1 is 600 and field 2 is 30 the change field 1 to 650.

    Hi ,
    I don't want to concatenate two fields nor display it in a single field, but I want to diplay two fields 1 below the other...
    ie..If I am using write statement I would prefer,
    loop at itab.
    wirte: /2 itab-abcd,
            /2 itab-1234.
    endloop.
    my output will be:
    abcd
    1234.
    If need to use da same logic in ALV how would I use ?? hope I am little more clear now..
    Please advice
    Karthik.

  • F4 HELP ON TWO DIFFERENT FIELDS OF A SCREEN .

    Hi Experts ,
    I have a screen  in which i have to aply f4 help on two different fields .
    1. Bussiness unit
    2. SAP GL Account .
    I  have applied for  Bussiness unit. by :
    PROCESS BEFORE OUTPUT.
    MODULE STATUS_1013.
    PROCESS AFTER INPUT.
    MODULE USER_COMMAND_1013.
       PROCESS ON VALUE-REQUEST.
    field B_UNIT MODULE SEARCHHELP_F4.
    But how i can apply on SAP GL Account  ,i have to use one more POV module or i can do it by using the same pov which i used for Bussiness unit.
    Please tell me how i can do with little bit code example.
    Regards,
    Premraj

    Hi,
    use one more FIELD statement and create one more module for GL a/c in same POV event.
    ex
    FIELD <GL a/c fld name> MODULE <Module name>.

  • Input in one formfield go to two different fields in a MySQL tablerow?

    Hi, I hope you can help me with this.
    How can I have input in one formfield go to two different fields in a MySQL tablerow without having the visitor to type out his input out twice?
    With the second one I would like to use md5.
    Any help is greatly appreciated.

    How can I have input in one formfield go to two different fields in a
    MySQL tablerow without having the visitor to type out his input out
    twice?
    You would need to write your query with the WHERE clause when you update to say "WHERE user=$userid".  That's the most basic way.  The $userid variable would need to come from either a session or a cookie if the user is logged in and you don't want them to enter the information again.  Or if this is from a previous page, the $userid could just be equal to the $_POST variable after sanitization.
    With the second one I would like to use md5.
    That's even simpler.  Before submitting the form, just do $md5_pass = md5($pass);
    http://us.php.net/manual/en/function.md5.php

  • Formula that looks at two different fields

    Hi,
    I posted this request for help not too long ago but didn't clearly explain what is needed. 
    When text is entered into a field (currentgoal1, currentgoal2 - each equaling 1), the formula needs to look at a different field (point1, point 2 - each holds a list box of with points 1, 3, 5, or NA) to see if "NA" was chosen.  If NA was chosen (rather than a point, 1, 3, 5) then the goalcount (total number of populated currentgoal fields) needs to subtract 1 from goalcount.  
    currentgoal 1 = 1 point
    currentgoal 2 = 1 point
    currentgoal 3 = NA
    3 goals, 2 points, 1 point field with NA
    Since one of the current goals is has a point of NA, the overall count of currentgoals in the goalcount field (total number of populated currentgoal fields) should state 2 with the totalpoints field (all points fields added together) stating 2. 
    How can the formula be adjusted to subtract a currentgoal with a chosen point of NA? 
    Formula used now for counting current goals:
    goalcount = 0
    != null){
    = goalcount + 1;
    != null){
    = goalcount + 1;
    (Table3.Row3.currentgoal3.rawValue!= null){
    = goalcount + 1;
    if(Table3.Row4.currentgoal4.rawValue!= null){
    = goalcount + 1;
    if(Table3.Row5.currentgoal5.rawValue!= null){
    = goalcount + 1;
    if(Table3.Row6.currentgoal6.rawValue!= null){
    = goalcount + 1;
    if(Table3.Row7.currentgoal7.rawValue!= null){
    = goalcount + 1;
    if(Table3.Row8.currentgoal8.rawValue!= null){
    = goalcount + 1;
    if(Table3.Row9.currentgoal9.rawValue!= null){
    = goalcount + 1;
    if(Table3.Row10.currentgoal10.rawValue!= null){
    = goalcount + 1;
    if(Table3.Row11.currentgoal11.rawValue!= null){
    = goalcount + 1;
    if(Table3.Row12.currentgoal12.rawValue!= null){
    = goalcount + 1;
    if(Table3.Row13.currentgoal13.rawValue!= null){
    = goalcount + 1;
    if(Table3.Row14.currentgoal14.rawValue!= null){
    = goalcount + 1;
    if(Table3.Row15.currentgoal15.rawValue!= null){
    = goalcount + 1;
    = goalcount;
    this.rawValuegoalcount
    goalcount
    goalcount
    goalcount
    goalcount
    goalcount
    goalcount
    goalcount
    goalcount
    goalcount
    goalcount
    goalcount
    goalcount
    if
    goalcount
    (Table3.Row2.currentgoal2.rawValue
    if
    goalcount
    (Table3.Row1.currentgoal1.rawValue
    if
    var

    Sorry, I was trying to edit. Is this better?
    var 
    goalcount = 0
    if
    (Table3.Row1.currentgoal1.rawValue
    != null){goalcount
    = goalcount + 1;}
     if(Table3.Row2.currentgoal2.rawValue!= null){goalcount
    = goalcount + 1;}
     if(Table3.Row3.currentgoal3.rawValue!= null){goalcount
    = goalcount + 1;}
    this.rawValue= goalcount;

  • Two different invoices created for  one order for two different lines

    Hi All,
    I have an order with four line items that was shipped on the same day, invoiced on the same day and all lines have the same delivery number yet two inovices were created for this order..one for the first three lines and one for the last line.
    Can anyone please explain what can cause this to happen?
    Thanks
    A/A

    Hi Asgar,
    If a single order has been split into two invoices, you should check the values of the mandatory columns. During Autoinvoice, the grouping is based on the madatory columns and also your grouping rules. If any of the mandatory column has a different value, it will split into different invoice.
    Please refer the following metalink note for further details
    Subject: How Autoinvoice Grouping Works
    Doc ID: 98772.1
    Hope that helps.
    Thanks,
    Anil

  • 'Join' two different field types together into a String - possible in Java?

    Not entirely certain whether this is a straightforward Java or more of a JDBC question:
    I have two fields, one is a String and one an integer. I need to concatenate these fields together to form one String, prior to performing an insert on a table. ie:
    String s = dbRS.getString("partition_name");    //get full string
    String partstr = s.substring(0, 14);      // get first 14 (alpha) characters
    int new_partition_number = max_partition_number + 1;      //create new unique partition number, incremented by 1Now I have
    - a String (partstr - i.e. "TN1234567890_")
    - an integer (i.e. 50)
    (NB. The number has to be an integer because it is subject to calculation elsewhere.)
    I wish to join these together into a String ("TN1234567890_50") and use the field in an inserted row. I've tried using
    String partition_string = new StringBuffer(partstr).append(new_partition_number ).toString();... but this doesn't work.
    I read on a forum that it's impossible to cast an integer to a String in this way in Java, which sounds pretty incredulous from where I am! However my Osborne Java 2 Complete Reference doesn't mention it at all.
    Any assistance will be very gratefully received!
    Thanks.

    wonder why he thinks you can't append an int to a StringBuilder.
    Works fine. Might of course not yield the expected result depending on expectations, but it works just fine.
    But then, the coding conventions reminiscent of C don't bode well.

  • Can a single LOV return values to two different fields?

    Hi,
    I have a scenario where I already have a LOV in the form which is assigned to a Field A. This LOV returns the value to field A. I have another field B which needs the same list of values. I can assign the same LOV to the field B as well, but can the value selected be returned to B?
    I can create another LOV with the same record group, but just wanted to know if its possible to use the same LOV again.
    Thanks

    Hi Karuna,
    You can achieve this by providing a third column in LOV (whose column width can be set to 0 to prevent it from being visible in lov) which can be comma-separated of two fields. This third field can then be assigned to the form field. And a substr() function call can get you both values.
    Hope this helps,
    Anantha
    [http://askanantha.blogspot.com]

  • Same text two different fields on one form

    HI.  I am trying to create button that allows me to copy text from one field to another on the same form.  In other words, at the top of my form i have a field for a "last name".  Under certain conditions i want to copy that "last name" into another field.  the button next to the latter field would ask "is the last name the same?"  if i hit that button then i want the text in the first field to import to the second field.  i think i need to use javascript but i can't write the asp.  help?

    George,
    These are the fields i want to copy.  Does the script look correct?
    // Get the value of the fields
    var v1 = getField("LENDER").valueAsString;
    var v2 = getField("TRUSTEE").valueAsString;
    var v3= getField("BORROWER").valueAsString;
    var v4 = getField("DATED_3").valueAsString;
    var v5 = getField("RECORDED_ 3").valueAsString;
    // Set the values of the other corresponding fields
    getField("LENDER_2").value = v1;
    getField("TRUSTEE_2").value = v2;
    getField("BORROWER_2").value = v3;
    getField("DATED_4").value = v4;
    getField("RECORDED_8").value = v5;

  • Reg: Transfer order printout in two different printers

    Hello
    I have a specific requirement
    My client is asking for print out for pick list transfer orders in two different printers based on the storage type. I have configured the set up in OMLV . Sorting ,profiles etc etc but it deosn't work.
    lets say for ex in pick list there are around 8 different storage types in which for only one storage type it should print in a different printer.rest all 7 storage type should print in one printer.
    Please help.

  • Two different Pricing date

    Hi Gurus,
    can pricing date in billing document be different for different line items?
    The scenario is two Sales orders having  two different pricing dates is combined into one delivery document. Next Invoice  is generated from that delivery document. But in Invoice the pricing date is same for both SOs which is system date or any selected date(as per choice).  Can one single invoice have two different pricing dates depending upon sales order pricing dates?
    As per my understanding the pricing date in Invoice is item based. Pls correct me if iam wrong.
    Regards,

    HI Sd
    One invoice is having one billing date only. Its not possible to have different billing date for different line item.
    But if we are copying the pricing directly from sales order without redetermination then one single invoice can have two different pricing dates depending upon sales order pricing dates.
    bye
    Edited by: Yadav on May 5, 2009 10:27 AM

  • Pupulating two database fields from one form field

    Hopefully an easy query for someone with more experience than
    me!!!
    I have set up a form (PHP page) to add new users to a table
    in a MySQL database. So far, so good.
    The problem is that I want to use the value entered in one of
    the form fields (Email) to populate two different fields in the
    table (username and email). I realise that this is redundant, but
    it is necessary for other reasons that I won't go into here...
    I've tried using a hidden input field for username, but I'm
    just not sure what I need to specify for 'value'...
    The code for the input field is:
    <input name="Email" type="text" class="RequiredInput"
    value="" size="32">
    and the code for the hidden input is:
    <input type="hidden" name="username" value=Email>
    As you can see, this puts the text 'Email' in the field,
    rather than the value of the Email input...

    When I try an post a reply with the code attached I get this
    screen:
    The page you requested could not be found on our web site.
    You may wish to try one of the following links:
    Search
    Search the Adobe web site.
    Adobe Homepage
    Go to the Adobe homepage.
    Macromedia Flash Player
    Download the Macromedia Flash Player.
    Broken Link?
    Send us an e-mail.
    When the forum's working again I'll have another go at
    posting the code...

  • Sapscript - displaying two text fields after truncating the spaces.

    Hi Friends,
    In a sapscript, I have to display the name of the vendor which is in two different fields each of length 40 chars. The first one may be filled to the maximum and the remaining goes into the second field and may occupy only 30 or 35 chars. I need to display the two side by side and the space available is 70 chars. I am using an existing script and I am not able to print the two side by side. It is going to the next line. How do I truncate the trailing spaces of either field. Please help. It is quite urgent.
    Thanks,
    BP.

    Hi Bindu,
    use the perform to concatenate name1 and name2 to NAME and use this field in address command.
    Check with the following code:
    /:   DEFINE &ZNAME& = ''
    PERFORM ADDRESS IN PROGRAM 'PROGRAM'
    USING    &REGUH-ZNME1& 
    USING    &REGUH-ZNME2&                             
    CHANGING &ZNAME&                       
    ENDPERFORM                                      
    FORM address
              TABLES itab STRUCTURE itcsy
                     otab STRUCTURE itcsy.
    LOOP AT itab.
        CASE itab-name.
          WHEN 'REGUH-ZNME1'.
            l_name1 = itab-value.
          WHEN 'REGUH-ZNME2'.
            l_name2 = itab-value.
        ENDCASE.
      ENDLOOP.
    use the logic.
    Endform.

  • Two Different Project to handle Project Manufacturing Cost ?

    Hello Guys,
    Can any One Help me on this Question,
    Sales Company - > Attaching their Project/Task to Sales Order.(Different OU,LE,Set of Books).
    Manufacturing Plant - > Imports the Sales-Order of Sales Company(Different OU,LE,Set of Books).
    Current Flow - > Sales Company Project/Task -> Planning -> Work Orders ->Transfer Cost to Projects.
    And Manufacturing Unit will create their Internal Project.
    Questions :-
    Now Manufacturing Unit wants to know their Manufacturing Cost(Material Cost,Resource Cost and Overhead Cost) ?How to track cost for Manufacturing Plant ?
    How we can transfer the cost from Sales Company Project to Manufacturing Project ?
    Do we need to Transfer from Cost from Sales Company OU to Manufacturing Internal Project OU ?
    Is their any other way to do the setups ?
    Iam only concened about How to use Sales Company Project and Manufacturing Internal Project ?
    Regards,
    Satish

    Hi Dina,
    We are in a process to implement flow of information between Sales Order from two different LEs.
    Our Order originates from Sales Service Org(Project Owning Org) ----> Trading Hub------- > MFG Plant. The equipment is shipped directly to customer.
    We would like to know more on the solution which you have explained : -
    "Manufacturing plant may use the same project as setup by the sales company. They could setup the transfer price rules for cross charge. Then run the Inter-company billing process which generates a sales invoice in the manufacturing OU AR, and interface that as internal supplier invoice to the AP of the Sales OU. To implement the Inter-company billing you need to follow the required setups in both OUs."
    We have been following steps and found not working
    (1) Created Project under Sales & Service Operating Unit (OU)
    (2) Created Sales Order against this Project in Sales & Service OU, the shipping org on this sales order is MFG which belongs to different entity &  OU.
    (3) Pick and Ship from shipping org MFG OU
    (4) Run Cost Collection Manager for Inventory Cost Transfer for the Shipping Org MFG
    (5) There is no transaction pending for this cost under Sales & Service OU, however this is pending under MFG OU (shipping Org)
    (6) Ran the "Transaction Import" program from MFG OU and the transaction got rejected as the Project belongs to Sales & Service OU.
    Thanks,
    Sachin Salvi

  • How to process reports with two different date fields

    Morning all,
    This question is somewhat similar to what I asked few days back. I created two different reports for two different departments (Credit Control and Free of Charge Control).
    These two reports pull data from two different date fields and has different status check ups.
    Few days back my director requested me if he can have both reports in one report. That is when I asked question from all of you regarding two reports.
    Anyhow, that was created by implementing two sub reports however, the director asked me to combine the two different reports into one in such a way that the output records should be added up with each other hence one single report with all combined data of Credit Control and Free of Charges (not two sub reports in one report).
    The problem here which I am getting is that, both reports uses two different date fields. I can live with two different statuses as that can be easily done within formula/RT however how to create a report with Report Selection Formula condition which looks in both date fields and produces results accordingly?
    I have tried this by not putting any condition in report selection formula and ran the report, it produced total results from past 6 years.
    Any ideas how to produce combined report which has two different date fields?
    Many thanks in advance
    Regards
    Jehanzeb
    What I

    Charliy,
    No the both dates are from two different databases, tables and fields. The Credit date field is from KLAB database under max table where as the FOC date field is from SAE database under maxmast table. Klab date is under credit2 table where as foc date is under order header table.
    So its more like this:
    Klab->Max-Credit2--->Credit_date
    Sae->Maxmast->Order_header---Date entered.
    two dates totally different tables, dbs
    however, I will try your idea too and see if that works.
    Regards
    Jehanzeb

Maybe you are looking for

  • MDX open interface error?

    has anyone come across this error in Excel client? i get it when trying to remove 0's from the summarized values. [MDX error|http://misiorek.com/mdx/MDX06.jpg] apologies for small screenshot but this is a resolution for full screen and screen scraper

  • Copied files from old hard drive to new hard drive now I have 2 logins how do I merge the 2 logins into 1

    New to apple computers.  have been repairing windows pcs and laptops since the dos days.  mobo on imac went bad. got a new new aio with 10.8.5.  pulled hdd from imac and copied files to new hdd. now I have 2 logins.  how do I merge them into one logi

  • Memory Leak in 8.1 sp5

    Has anyone experienced a memory leak when a webservice (jws) returns a large string (5-15 Meg). The string itself is a XML. When the webservice is called numerous times it eventually runs out of memory.

  • Delivery Output

    Hi Everybody, We have a delivery output type ZASN. The output type has a requirement 1 assigned in the output determination procedure. The requirement is to make the output get determined only after the PGI has been done. We have all our Picking and

  • Sort folders by date

    In the thumbnail view the newest pics are at the bottom, the oldest at the top. Great. But in my list of folders on the left panel, they're sorted by name, and I get figure out how to sort that list of folders so the newest ones are at the top. Like