Finding max() within a max() or highest value in 1row-1col w. multi-value

Hi,
I am trying to get a result set that has following criteria
- for rows using the same WEL_FK column, I'd like the latest date
and within the latest date the highest weight. (Sort of a max() within a max()) for each WEL_FK).
-if there is a row that has no other matching WEL_FK;s (like row 8)
it should still return that row.
PER_PK WEL_FK A_DATE WEIGHT
1 1 2010-10-22 4
2 1 2010-11-23 4
3 1 2010-10-22 6
4 3 2010-10-22 2
5 3 2010-11-23 2
6 3 2010-10-22 2
7 4 2010-10-22 5
8 6 2010-10-22 5
9 6 2010-10-21 6
10 6 2010-10-22 4
10 rows selected.
RESULTS desired
PER_PK WEL_FK A_DATE WEIGHT
2 1 2010-11-23 4 because it has the latest date within same foreign key even if wt. not the highest
5 3 2010-11-23 2 because it has the latest date within same foreign key, wts. are equal
7 4 2010-10-22 5 because there are no other rows with that WEL_FK
8 6 2010-10-22 5 because it has latest date with highest wt.
I am able to get close to what I want using the SQL below which gives me correct rows
but does not tell me the "weight" nor "PER_PK" column.
I have been trying to find a way to pick highest value from 1 ROW and within 1 column
with multiple-values but think I have dug myself into a hole.
When I add in the PER_PK above, it gives me of course all 10 rows again.
SELECT wel_fk,
LTRIM(MAX(SYS_CONNECT_BY_PATH(a_date,','))
KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
FROM (SELECT wel_fk,
a_date,
ROW_NUMBER() OVER (PARTITION BY wel_fk ORDER BY a_date) AS curr,
ROW_NUMBER() OVER (PARTITION BY wel_fk ORDER BY a_date) -1 AS prev
FROM test)
GROUP BY wel_fk
CONNECT BY prev = PRIOR curr AND wel_fk = PRIOR wel_fk
START WITH curr = 1;
WEL_FK EMPLOYEES
1 2010-10-22,2010-10-22,2010-11-23
3 2010-10-22,2010-10-22,2010-11-23
4 2010-10-22
6 2010-10-21,2010-10-22,2010-10-22
==========================================================
I have been exploring analytics, connect by's, subqueries, wm_concat, SYS_CONNECT_BY_PATH ,etc. along with max()for days and get real close
but somehow it's off.
If you are able to provide actual SQL solution, ideally using what I have already, would be appreciated.
Thanks.
the_sql

Try this:
WITH src AS (
SELECT per_pk,
       wel_fk,
       a_date,
       weight,
       MAX( a_date ) OVER (PARTITION BY wel_fk ORDER BY a_date
                  RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) latest_date,
       last_value( weight ) OVER (PARTITION BY wel_fk ORDER BY a_date, weight 
                  RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING ) max_weight
FROM TEST
SELECT per_pk,
       wel_fk,
       a_date,
       weight
FROM src
WHERE a_date = latest_date
     AND weight = max_weight
PER_PK                 WEL_FK                 A_DATE                    WEIGHT                
2                      1                      2010/11/23                4                     
5                      3                      2010/11/23                2                     
7                      4                      2010/10/22                5                     
8                      6                      2010/10/22                5       

Similar Messages

  • Finding Max of Dimension values

    Hi ,
    I want to find the Maximum value of a parituclar dimension( ex: TopSellers dimension has values like 100,200,700,300 etc.).
    What could be the query parameter that we can use while querying.
    Thanks,
    Unnam

    Hello Unnam,
    If you are in a situation where you have too many refinement values to return just for the purposes of getting the min/max values or you are using the "More..." functionality and sorting alphabetically, there is another feature that will allow you to get min/max and other values - analytics queries. This may require additional licensing from Oracle, you'll have to check.
    For the details:
    http://docs.oracle.com/cd/E28910_01/MDEX.622/pdf/AnalyticsGuide.pdf
    Your analytics query will be very simple compared to what's in the guide above.
    Analytics need to be enabled in the ./MDEX/6.X.X/conf/ProductConfig.xml file, adding the following line within the <PRODUCT_CONFIG> element:
    <FEATURE NAME="Analytics API" ENABLE="TRUE"/>
    The following is an example Analytics statement that can be used to capture the min and max value for the p_Fee property in a given navigation state:
    RETURN FeeStmt AS SELECT MIN(p_Fee) AS MinFee, MAX(p_Fee) AS MaxFee GROUP
    This statement can be added to the basic ENEQuery object in the application code as in the following example:
    ENEQuery query = ...
    String analyticsFeeStr = "RETURN FeeStmt AS SELECT MIN(p_Fee) AS MinFee, MAX(p_Fee) AS MaxFee GROUP";
    AnalyticsQuery analytics = AnalyticsQuery.parseQuery(analyticsFeeStr);
    query.setAnalyticsQuery(analytics);
    The results can be retrieved from the returned Navigation object using Navigation.getAnalyticsStatementResult(), as in the following example:
    Navigation nav = ...
    AnalyticsStatementResult analyticsFeeResult = nav.getAnalyticsStatementResult("FeeStmt");
    long numAnalyticsERecs = analyticsFeeResult.getReturnedNumERecs();
    String minFee = "";
    String maxFee = "";
    if (numAnalyticsERecs > 0) {
    ERec analyticsFeeERec = (ERec) analyticsFeeResult.getERecIter().next();
    minFee = (String) analyticsFeeERec.getProperties().get("MinFee");
    maxFee = (String) analyticsFeeERec.getProperties().get("MaxFee");
    -Tim

  • To find the number that has the highest value

    I have an internal table with one field containing numeric values. I want to know the number that has the highest value. Can you tell me how do I do that?
    Is there any keyword for this?
    Thank you,
    Krishen

    Hi,
      Use the below procedures..
    <b>CASE 1</b>
    SORT <itab> by <Fld>
    where <itab> - Internal Table.
    and <Fld>     - Field Name ( in your case it is the field with numeric values)
    describe table <itab> lines <no_of_lines>
    <no_of_lines> - total number of lines in the table.
    read table <itab> index <NO_OF_LINES>
    the above read statement gives the highest record.
    <b>CASE 2</b>
    SORT <itab> by <Fld> descending.
    where <itab> - Internal Table.
    and <Fld>     - Field Name ( in your case it is the field with numeric values)
    read table <itab> index 1.
    the above read statement gives the highest record.
    I hope this solves your problem.
    Regards,
    Vara

  • Finding Max and Min values

    Hi Gurus,
    I have a table with one column as data type NUMC of lenth 5.
    Now, I have to get the max value and minimum value from that column into two variables of same type.
    Could you please help me with the logic and code in ABAP.
    Thanks,
    Regards,
    aarthi

    select single MAX( <field> ) from table into <variable>.
    select single MIN( <field> ) from table into <variable>.
    Message was edited by:
            S B

  • Find max of 3 values

    Hello,
    I am currently performing an update using a CASE statement, however my last condition is when I'm stuck:
    UPDATE X
    SET DATE =
    CASE WHEN RATE = 'a' THEN
    DATE_IN + ((col1 / col2) * 7)
    ELSE
    CASE WHEN RATE = 'b' THEN
    DATE_IN + ((col1 / col2) * 7)
    ELSE
    CASE WHEN RATE = 'c' THEN
    DATE_IN + ((col1 / col2) * 7)
    else
    case when rate = 'd' then
    ****HERE IS THE ISSUE****
    END END END ;
    When the rate is 'd', I need to use the max of the other 3 rates.
    Any comments would be appreciated.

    shane_1004 wrote:
    Hello,
    I am currently performing an update using a CASE statement, however my last condition is when I'm stuck:
    UPDATE X
    SET DATE =
    CASE WHEN RATE = 'a' THEN
    DATE_IN + ((col1 / col2) * 7)
    ELSE
    CASE WHEN RATE = 'b' THEN
    DATE_IN + ((col1 / col2) * 7)
    ELSE
    CASE WHEN RATE = 'c' THEN
    DATE_IN + ((col1 / col2) * 7)
    else
    case when rate = 'd' then
    ****HERE IS THE ISSUE****
    END END END ;
    When the rate is 'd', I need to use the max of the other 3 rates.The "other 3 rates" are all the same:
            DATE_IN + ((col1 / col2) * 7) Assuming they were different, you could use the GREATEST function. Make sure none of the arguments to GREATEST are NULL.
    To avoid repeating some computations, you can do them in a sub-query, and refer to the column aliases in the main query. When doing an UPDATE, this will probably be slower; only you can tell if the programming convenience is worth the extra execution time.
    As Alex said, post some sample data and the results you want from that data (that is, the contents of the table after the UPDATE) if you want help.

  • Finding MAX/MIN value

    Hi!
    There are different records in PSA.
    When I load to DSO I need only max value for key figure.
    For example, data in PSA:
    Char| KF
    1| 2
    1| 5
    1| 3
    2| 1
    If I use Overwrite then result is:
    1| 3
    2| 1
    If I use Sum then result is:
    1| 10
    2| 1
    But I need followed reult:
    1| 5
    2| 1
    How can I find max value for KF without using FM or Programs?

    Hi,
    You can do this in a Start routine.
    Sort the source package and copy the records with the max value to another internal table which has the same structure as your source package.
    In the end of the routine, over write records in source package with the records in the internal table.
    THis will help.
    - Jaimin

  • How to find max based on 2 columns.

    Hi I have a table where I have two numeric fields (date and time) )(thouse field are not date time format but numeric)
    Column A represents date and column B represent time.
    How would I find max value of column A and with results for A find Max for B.
    example
    A - - - - - - - - - -B
    101010 - - - - - 202020
    101011 - - - - - 202021
    101012 - - - - - 202021
    101010 - - - - - 202022
    101012 - - - - - 202020
    What I looking for is
    A - - - - - - - - - - B
    101012 - - - - - 202021
    Thanks

    You can try one of the following...
    sql> select * from temp;
             A          B
        101010     202020
        101011     202021
        101012     202021
        101010     202022
        101012     202020
      1  select a,b from (
      2     select a,
      3            b,
      4            rank () over (order by a desc, b desc) rnk
      5       from temp
      6* ) where rnk = 1
    sql> /
             A          B
        101012     202021
      1  select a,b from (
      2    select a,b from temp
      3       order by a desc, b desc
      4* ) where rownum = 1
    sql> /
             A          B
        101012     202021Please try to provide create table statements and insert data scripts instead of "select * from table".
    It helps creating your case easier.

  • Thread use to find max and min in an array of objects??

    Hello everyone,
    I need to find the min and max int value in a array of Objects.
    This has to be done using threads--like divide the entire array into 10 or so blocks and find the local min and max in each block., Each block is run on a thread and finally comparing them to find the global max and min.How should I do this? I am new to Java programming and in particular to threads.
    Thanks for your time and patience in answering this newbie question.
    JP

    Hi,
    if i understand your problem, you have a big array with a lot of int values and you need to create a few arrays with a part of the big one in each, next each in a thread find the max and the min, next return the max and the min of each thread and compare these max and min to obtain the globals max and min?
    In that case you can create a class in which is your big array. you create a second class implementing Runnable, in its creator you put the instance of the
    first class and 2 int which are the beginning and the ending index. in this class add a method run in this method you create a loop to compare the current value to the max and min values, and you replace if you need to do. In the first class you put the main where you create a few instance of the second class in a thread :
         private Thread threadName = new Thread(new SecondClass(this, start, end));
    Next you start all these thread:
    threadName.start();
    At the end of the run method of the second class you have to write your result in the max and min fields of the first class(int type, you have to create it)
    Write it only if it's necessary (if the current max is > than the already existing max).
    I think it's complete!
    Sorry if it's not really easy to understand, I'm french, but you can answer if you have more questions.
    S�bastien

  • Max.cond.base value - wrong line totals in Sales Order and Invoice

    Dear Experts,
        In my pricing procedure, I have set the field Max.cond.base value as 1 in VK12 (in additional data) for one of my condition type ZR16 . If Max.cond.base value is set as 1 for ZR16 condition type, the value for ZR16 will be considered only for the 1st quantity for that item. All subsequent quantities for that item will not be considered. This works fine in Sales Order and when I enter the same material in 2 line items with qty 1 each, only the first line item considers ZR16 value in total net value and the second line item does not consider the value of ZR16 in the total, which is correct.
        Problem arises when I create individual deliveries and individual invoices for each line item. Although the ZR16 value is not considered in the total for the second line item in the sales order the value is being considered in the invoice which is wrong. I tried various scenarios and found this issue arises only with domestic customer and not with overseas customer. Issue is that the line total value value calculated correctly in sales order is reflecting wrongly in Invoice when I use Max.cond.base value. I am confused if this is a pricing procedure related issue or copy control related. Please share your valuable inputs.
    Regards,
    Madhavan

    I tried various scenarios and found this issue arises only with domestic customer and not with overseas customer
    Compare the access sequence combination and condition record in both the above cases and check which one is differing and creating issue.
    the line total value value calculated correctly in sales order is reflecting wrongly in Invoice
    Again here also, compare the Analysis tab which should be self explanatory to find out the root cause of the issue.
    G. Lakshmipathi

  • Max cond value vs max cond base value

    Hi All,
    What is the difference between
    Maximum condition value & Max condition base value, in the condition records. (VK11,12,13)
    Path - Maximum condition value:-
    VK13 --> condition records --> add sales data --> max cond value
    For Path Maximum condition base value, i cant see the field out there on the screen
    PL help with the differences between the functionality, appreciate, if it is with an example
    Jimit Shah

    Hi Jimit,
    I think it should be ' Condition Base value " and "Max condition value " I may be wrong.
    Conditional base value  When a value is derived for a condition type, based on certain calculation this value is taken as base.
    Condition base value is a concept used in pricing procedure and actual term used is alternate condition base value. This is a formula assigned to a condition type in order to promote an alternate base value for the calculation of the value. If you have to calculate price of a material then you have to have a base value for it. For e.g. if you want to calculate the discount of 10 % for a material then you have to have a base value on which this 10% is calculated. Normally you take the condition value of the base price of the material to calculate the value.
    Max condition  value, Provided that the condition update function is active for a particular condition type, you can create condition records that specify a maximum cumulative value. The system uses the condition value of an item as the basis for the cumulative value.
    You can specify the maximum value when you maintain an existing condition record. The condition update indicator must be maintained in Customizing for Sales for the corresponding condition types.
    For example, specify that a customer receives a 10 USD discount for a particular material up to a maximum cumulative order quantity of 5,000 cases. As the customer places sales orders for the item, the system keeps track of the cumulative value (in this example, the number of cases) and stores this data at the condition record level. Once the cumulative value reaches 5,000 cases, the system automatically deactivates the discount. ( Source help.sap.com )
    To view the cumulative value for a particular condition record:
    Within the condition record, choose Extras > Cumulative values.
    A dialog box displays the cumulative value of sales orders where this condition record was used.
    Thanks/Rajesh
    Edited by: Rajesh Kumar Bhansali on Mar 2, 2011 5:40 PM
    Edited by: Rajesh Kumar Bhansali on Mar 2, 2011 5:41 PM

  • I am a rookie and need help with max and min values

    Hello all, i am into this intro to java class. my assignment is to write a program that prompts the user for two integers and then prints the sum, difference, average, product , distance (absolute value of the difference) Maximum(largest of the two) and Minimum(smallest fo the two) here is my code so far
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.lang.Math;
    public class Sample4
       public static void main(String[] args) throws IOException
          try // attempt the following
    {           // create the stream to read from
    InputStreamReader istream = new InputStreamReader(System.in);   // create a buffer to hold the stream
    BufferedReader console = new BufferedReader(istream);           // prompt the user
          System.out.println("Enter a number please");              // get input as a string
          String input = console.readLine();                        // convert to an integer
          int num1 = Integer.parseInt(input);
          System.out.println("Enter a number please");              // get input as a string
          String input2 = console.readLine();                       // convert to an integer
          int num2 = Integer.parseInt(input2);
          int sum = num1 + num2;                                    // get the sum of the two inputs
          int difference = num1 - num2;                             // get the difference of the two inputs
          int product = num1 * num2;                                // get the product of the two inputs
          int average = sum / 2;                                    // get the average of the two inputs
          int abs = Math.abs(difference);                           // get the absolute value of the two inputs
              // new section
                 // display the number
          System.out.println("The total sum = " + sum);
          System.out.println("The total difference = " + difference);
           System.out.println("The total product = " + product);
           System.out.println("The total average = " + average);
           System.out.println("The total absolute value = " + abs);
    } // if something breaks, catch the exception
    catch (IOException e)
       System.out.println(e); // displays the exception
       System.exit(1);  // quits the program
    }what will be the right syntax or code to find the MAX and MIN values of two numbers a User Inputs, hope someone can help with this. thank you for your help.

    Thanks alot man, sheesh i do not know why my book
    doesnt give me all the static methods. but i do really
    appreciate your help. peaceA complete list of the java.lang.Math methods can be found at http://java.sun.com/j2se/1.4/docs/api/java/lang/Math.html
    btw,
    max(a, b) == (a > b) ? a : b
    min(a, b) == (a < b) ? a : b

  • Wht s max sizelimit of value in(property-value pair)of content typ in CMS

    For a content type we create many properties in administration console. eg.Name, FIle, Desc
    wht s max sizelimit of value in(property-value pair)of content typ in CMS, where i hav defined the property as string.

    In WLP 10.0, the maximum String property length was increased.
    I believe the max String property length depends on the DB type. It always at least 4000 characters. For Oracle, it is 4254 characters.
    More info at http://edocs.bea.com/wlp/docs102/db/data_dictionary.html#wp1090682
    -Steve

  • In Oracle 10g, what is the max number of values we can pass to  'IN' Clause

    Hi,
    In my SQL query i have a scenario like, i have to pass the values to 'IN' Clause dynamically from other application. I want to know what is the the max number of values i can pass to 'IN' Clause.
    i have searched in many pages i seeing answers like 'may be 1000' , 'not sure'....
    Could any one tell me the exact limit of IN Clause in 10g.
    Thanks in Advance.
    Chandran

    Hi, Chandran,
    Chandran M wrote:
    In my SQL query i have a scenario like, i have to pass the values to 'IN' Clause dynamically from other application. I want to know what is the the max number of values i can pass to 'IN' Clause.
    i have searched in many pages i seeing answers like 'may be 1000' , 'not sure'....Don't overlook [Dont want to know|http://forums.oracle.com/forums/thread.jspa?messageID=2683385&#2683385]. This may explain why people are reluctant to give a straight answer.
    Could any one tell me the exact limit of IN Clause in 10g.1000 items such as IN (1, 2, 3, ..., 1000)
    No limit on the number of sets: IN ((1), (2), (3), ...) *<=== NOT QUITE!* See below
    No limit in sub-queries: IN (SELECT ...)
    Edited by: Frank Kulash on Jun 3, 2009 9:43 AM
    The limit of 1000 applies to sets of single items: (x) IN ((1), (2), (3), ...)
    There is no limit if the sets contain two or more items: (x, 0) IN ((1,0), (2,0), (3,0), ...)
    Thanks to Michaels for pointing this out.
    Edited by: Frank Kulash on Jun 3, 2009 10:22 AM
    Fixed link

  • How to use my findTheHighest method to find the highest value in my two dim

    I am going to create a 13row by 10 colume two dimensional array.
    how to use my findTheHighest method to find the highest value in my two dimensional array.
    .When i compile this program , i got those as following;
    "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsExce
    at TaxEvolution.findTheHighest(TaxEvolution.java:31)
    at TaxEvolutionClient.main(TaxEvolutionClient.java:25)"
    public class TaxEvolution{
    public double[][] salesTaxRates;
    public TaxEvolution()
      salesTaxRates = new double[13][10];
      fillProvinTaxRates();
    private void fillProvinTaxRates()
      for ( int row = 0; row < salesTaxRates.length; row++ )
        for ( int column = 0; column < salesTaxRates[row].length; column++ )
          salesTaxRates[row][column]= (int)(Math.random()*5000) + 1;
    public double findTheHighest()
        double highest = salesTaxRates[0][0];
        for ( int row = 0; row <= salesTaxRates.length; row++ )
          for ( int column = 0; column <= salesTaxRates[row].length; column++ )
             if ( salesTaxRates[row][column] >= highest )
                   highest = salesTaxRates[row][column];
        return highest;   
    public double[][] arrayTaxEvolution()
      double[][] returnTaxRates = new double[13][10];
      for ( int row = 0; row < salesTaxRates.length; row++ )
        for ( int column = 0; column < salesTaxRates[row].length; column++ )
          returnTaxRates = salesTaxRates;
      return returnTaxRates;
    public class TaxEvolutionClient{
    public static void main( String[] args ){
      TaxEvolution protaxRateList = new TaxEvolution();
      double[][] taxRateList = protaxRateList.arrayTaxEvolution();
        for ( int i = 0; i < taxRateList.length; i++ )
          for ( int j = 0; j < taxRateList[0].length; j++ )
            System.out.print( taxRateList[i][j] + "\t" );               
            System.out.print( protaxRateList.findTheHighest + "\t" );
    }

    Multiposted
    http://forum.java.sun.com/thread.jspa?threadID=699057&tstart=0

  • Query to find max on UNION

    Hi ALL,
    I need to find max date from a union result. I tried to use bellow query,
    select max(last_processed) from
    (select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_ORGS UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_NOTES UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT_LKUP UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_ORGANISATIONS UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT_LKUP UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_INDIVIDUALS UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_COUNTRIES UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_ADDRESSES);
    This is not working give ORA-00904: "LAST_PROCESSED" invalid identifier.
    I tried a SELECT from (....) as follows*
    select * from
    (select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_ORGS UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_NOTES UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT_LKUP UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_ORGANISATIONS UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT_LKUP UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_INDIVIDUALS UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_COUNTRIES UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_ADDRESSES)
    This is woking perfectly. But when I tried to do max(*) i.e select max(*) from ......... gives error again.
    Can some one suggest me a query to full fill my requirement please.
    Thanks
    Rupesh
    www.orachat.com

    Hi, Rupesh,
    rupesh.sreenivas wrote:
    Hi ALL,
    I need to find max date from a union result. I tried to use bellow query,
    select max(last_processed) from
    (select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_ORGS UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS_NOTES UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_USERS UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT_LKUP UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_SUBS_CONTENT UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_ORGANISATIONS UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT_LKUP UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_MEDIA_CAT UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_INDIVIDUALS UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_COUNTRIES UNION
    select max(date_processed) "last_processed" from GMD.CHANGELOG_ADDRESSES);
    This is not working give ORA-00904: "LAST_PROCESSED" invalid identifier.
    Anything inside quotes (including double-quotes) is case-sensitive. Everything not in quotes is capitalized before compiling. So
    last_processed is the same as
    "LAST_PROCESSED", but different from
    "last_processed".
    Don't use double-quotes.

Maybe you are looking for