Select the maximum value

Dear Friends
I want to select the maximum value according to the following script
select H_TRANS_DATE,NVL(D_CURRENT_METER,0) INTO L_DATE,LOC_VAR
from (select d_current_meter,H_TRANS_DATE
FROM MAINTENANCE_HEADER
WHERE H_CAR_NO=:REC_MASTER.H_CAR_NO
AND MAINTENAMCE_STATUS = 2
order by H_TRANS_DATE desc)
where rownum = 1;
it works fine in sqlplus and it gives the correct result, but when I copy the same code to my Oracle Forms Builder it gives the following Error 103 at line 23 column 16 encountered symbol “ORDER” when
expecting one of the following) * &
When I remove the order by the error message goes but I am not getting the correct result ,how can I correct this script
Best Regards
Jamil

Yes I have copied/pasted the correct code ?
and the field name in the database same as the following
AND MAINTENAMCE_STATUS = 2
any other idea , and my form version is
Forms [32 Bit] Version 6.0.8.11.3 (Production)
Oracle Toolkit Version 6.0.5.35.0 (Production)
PL/SQL Version 8.0.6.0.0 (Production)
Oracle Procedure Builder V6.0.8.11.0 Build #449 - Production
Best regards
Jamil

Similar Messages

  • How to find out the maximum value in a Query within single material

    Dear all,
    Im creating a Query on 0SD_C03 where i have to disply Maximum value of a material which is having more that one transaction..
    EX:
    MATERIAL BILLED VALUE
    x with BILLED VALUE 100
    x with BILLED VALUE120
    y with BILLED VALUE 50
    y with  BILLED VALUE 80
    z with BILLED VALUE 50
    z with BILLED VALUE 60
    in a analyser i have to display X with billed value 120 that is max in X material and
    Y with billed value 80 that is max in Y material and
    Z with billed value 60 that is max in Z material
    In a query all the values are summing up. I.e for X its 220 and Y its 130 and Z its110 but we dont want to get total sum value we want individual values and the maximim of those values.......... 
    We are using BW 7.0 version
    Can any one help me out in this
    Thxs in Advance
    Venu

    Venu,
    In your query try creating a formula, with the value of each record as the key figure in the formula.
    In the aggregation tab select maximum in the exception aggregation dropdown and then select material as the reference characteristic
    then when you include material in the rows it will only display the maximum value.
    cheers
    mark

  • How to check the maximum Value and Last value in Reports CP column

    Hi all
    First of all i am sory that iam posting this question in forms instead of Reports....i had posted it in reports but no one reply and i need uirgent solution so I post here....
    My problem is that in Report I have calculated some values in CP column......Like
    :CP_Total := :Frieght * Rate ...etc
    Know i want to ask that how can I get the last value that will be return the by this column????and also the maximum value that it will return
    Thanks in advance
    Shayan
    [email protected]

    You mast build Summary column out of the query and select maximum to your maximum value of CP in Report level (or last for last value).

  • How to define in the optional the clause, the maximum value of a colum

    Hi!
    I'm using select data block from database toolset.
    I want to use optional clause wiring to import only the maximum value of the column 2.
    E.g. to import only the values greater than 1 you have to wire a string like this col2>1. But i don't know which string i have to wire to iport the maximum value of this column.
    Thank you in advance.
    Larson

    Hi Larson
    To select row n you either need a certain value (e.g. an index or something you know is unique in row n) or you select all values and extract one row in LV.
    So the first statement would be "SELECT * (* means all columns, you could also specify the columns as well) FROM data WHERE [a value = another value]. This would give you just the rows where the where-clause is correct. The other way is to select all data and just extract row n from the array you get from the recordset.
    There might be other ways, but these are two solutions I just had in mind.
    Manuals - just google the internet for SQL (Structured Query Language) and you will find lots of websites providing this information.
    Hope this helps.
    Thomas
    Using LV8.0
    Don't be afraid to rate a good answer...

  • How can we select the highest value from 3 disfferent #defined values???

    Hello,
    Sometimes I come across the requirement of having the program automatically select the highest value
    among several defined preprocessor command statements. For example:
    #include "stdio.h"
    #include <math.h>
    #define _K_BUF_OTHERS 20
    #define _k_BUF_ENV_TAGS 30
    #define _k_BUF_REGS 40
    #define _k_MAX(x, y, z) (max((max(x, y)), z))
    int main(){
    unsigned int u;
    u = _k_MAX(_k_BUF_OTHERS,_k_BUF_ENV_TAGS, _k_BUF_REGS);
    return 0;
    In the sample above we have three (3) different define statements called :
    _k_BUF_OTHERS
    _k_BUF_ENV_TAGS
    _k_BUF_REGS
    but at any given time in certain C modules (In this case above, the main.c module) I require for the program to know
    which of the three is the highest and get that highest value so I can use it downstream of my code. In this case the highest would be 40. So therefore putting the following macro anywhere in my code should make a text substitution of the macro's value
    and return 40 to u:
    u = _k_MAX(_k_BUF_OTHERS, _k_BUF_ENV_TAGS, _k_BUF_REGS);
    But I can't even compile the program!
    Here's the error I get in VC++:
    1>------ Build started: Project: MinMax, Configuration: Debug Win32 ------
    1>  Source1.cpp
    1>c:\c++_tests\minmax\minmax\source1.cpp(15): error C3861: 'max': identifier not found
    1>c:\c++_tests\minmax\minmax\source1.cpp(15): error C3861: 'max': identifier not found
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    Can someone please have a look and see what I am doing wrong.
    All help appreciated...
    Thanks
    r

    On 4/12/2015 4:30 PM, roberto wrote:
     1>c:\c++_tests\minmax\minmax\source1.cpp(15): error C3861: 'max': identifier not found
    So implement or #define one. C standard library doesn't provide a function named "max".
    Igor Tandetnik

  • How to find out the maximum value of one array

    hi all..
    I have one array that consists of some elements
    so I want the maximum value of the list ...
    if anyone knows this please help me..
    thanks..

    >
    If your array is already sorted, you can do a binary
    search.
    I think there are already methods to do that in
    java.util.Arrays. (?)
    If not, it's not hard to find an example on the net.
    A binary search will be more efficient.1. If your array is already sorted, you do not need a binary search. Either check the value of arr[0] or arr[arr.length - 1] depending on the direction of sorting.
    2. If your array is not sorted, try this:
    int maxValue = arr[0];
    for(int index = 1; index < arr.length; index++)
      if(arr[index] > maxValue)
        maxValue = arr[index];
    }

  • How to find out the maximum value

    Dear all,
    i have one query where in i have to calculate Excise Duty based on the  maximum  sales qantity of all materials with the corresponding sales value... i mean i wil get the maximum value of a individual material no matter how many sales has done.i wil pick up the maximum sales qty and the correspondig sales value....
    This im able to solve by taking the condition as TOP 1..
    Now my question is if the same material qty is sold with differnt value then i have to pick up the  Max value and as usual the sales qty..... plz help me out
    Material              Sales Qty              sales value
           3000                10 kl                   1000INR
           3200                15 kl                   1100 INR
           4000                20 kl                   1000INR
    in this case my query is picking up the max qty of  20 and the value 1000 INR as i had taken TOP 1 on Sales qty ....
    <b>
    But In the below example  for the same material i have to pick up the 3 rd row  where the sales value is maximum and the corresponding sales qty 10 kl</b>
    EX   Material        Sales Qty              sales value
           3000                10 kl                   1000INR
           3000                10 kl                   1100 INR
           3000                10 kl                   1500INR

    Hi,
    U can use the restrict option fo the Material characteristics  for sales value just drag and drop on columns >right click Properties> U have the option Calculated Result as Summation, Maximum, Minimum etc..just choose Maximum for ur case.

  • Exchange Rate is picking the Maximum value, instead of valid from

    Every first day of month we enter exchange rates for foreign currencies.
    but when we make  Purchase Order or any other payments in foreign currency, system is picking the maximum value, but not the value from Validity date.

    Hello,
    Thanks for your immediate response.
    But my Question is for e.g.
    on 01.01.2010  entered Exchange rate is 1 euro = 5.6954 SAR
    on 01.02.2010  entered Exchange rate is 1 euro = 4.9653 SAR
    if am posting document on 16.02.2010 it should pick the second value i.e., 1 euro = 4.9653 SAR, but system is picking the maximum value.

  • How to select the larger value of column?

    I would like a cell value (here E8) to be for example: (max $E$1:E7) + B8. Where all previous E column values were find the same calculation except for E1 that is a simple number and not a calculation? It does not work. It give the result for E1 + B8. The larger value should be E7. So the correct result should be E7 + B8 but if there is no value in E7 I want it to choose the larger number of the E column so far. Does some one can help me?

    Hi Frederic,
    If I understand "Where all previous E column values were find the same calculation except for E1", you want each cell, starting at E2 to contain this formula.
    E2: =MAX($E$1:E1)+B2          E8: =MAX($E$1:E7)+B8
    If that's the case, then "there is no value in E7" would never occur, and, unless the value of Bn were negative, the maximum value in column E would always be the one immediately above the formula.
    In that case, this simpler formula would produce the same result:
    E2: =E1 + B2                        E8: =E7 + B8
    Regards,
    Barry

  • How to fetch the maximum values of 2 columns

    Hi All,
    I need to fetch the maximum value of 2 columns. For example I need to fetch the latest record for which i have to fetch the latest date and time. Date and time fields are 2 different columns. As of now am doing it the crude fetching the latest date records and then fetching the latest time record.
    Is there any other smarter way to do it. The one am doing rite now is turning out to be very performance intensive at the moment for me.  Also I could not apply max condition for two fields together.
    Please guide.
    Thanks,
    Nagraj

    Hi Jaspreet,
    Thanks for your response. But the problem am facing with this approach is I have to do this for n number of records in another internal table which is making it to cumbersome and affecting performance.
    Please suggest is there any better way to do it.
    Thanks,
    Nagraj

  • The maximum value of a maximum value without making two querys of the same

    Hi,
    In the table cmp_lineas_cotizacion i need to take only rows with the maximum lc.mto_precio_venta of the maximum l.fec_ini_vigencia_costo of l.cod_producto, but I have the problem that cmp_lineas_cotizacion is a very load table with take to much resources of the database, I can't modify or agregate indexes, so I need a way to make this query more efficient. I want to find a way to replace the last 6 lines of this query and make it faster.
    select b.segment1 || '.' || b.segment2 as ITEM,
            case when b.organization_id in (125,89,90,92,95,97,99,101,104,106,108,110,112,115,83,85,
                                                        87,88,91,93,94,96,98,100,102,103,107,109,111,113,114,116,
                                                        117,120,123,124,128,130,132,134,135,133,131,129,118,182)
                      then 1
                 when b.organization_id in (105, 126)
                      then 2
            end as ZONE_ID,
            replace(l.mto_precio_venta,',','.') as STANDARD_RETAIL,
           'VEF' as STANDARD_RETAIL_CURRENCY,
            case when b.primary_unit_of_measure like '%KG%' then 'KG'
                 when b.primary_unit_of_measure like '%Kg%' then 'KG'
                 when b.primary_unit_of_measure like '%UND%' then 'EA'
                 when b.primary_unit_of_measure = 'Kilogramo' then 'KG'
                 when b.primary_unit_of_measure = 'Litro' then 'L'
                 when b.primary_unit_of_measure = 'Unidad' then 'EA'
                 else null
            end as STANDARD_UOM,
            case when l.Mto_precio_venta_cm_emp is not null then replace(l.Mto_precio_venta_cm_emp,',','.')
                 else '0'
            end as SELLING_RETAIL,
            'VEF' as SELLING_RETAIL_CURRENCY,
             case   when b.PRIMARY_UNIT_OF_MEASURE like '%Barril%' then 'BA'
                    when b.PRIMARY_UNIT_OF_MEASURE like '%Bolsa%' then 'KG'
                    when b.PRIMARY_UNIT_OF_MEASURE like '%Bulto%' then 'BE'
                    when b.PRIMARY_UNIT_OF_MEASURE like '%Caja%' then 'CS'
                    when b.PRIMARY_UNIT_OF_MEASURE like '%Docena%' then 'CS'
                    when b.PRIMARY_UNIT_OF_MEASURE like '%Kg%' then 'CS'
                    when b.PRIMARY_UNIT_OF_MEASURE like '%Kilogramo%' then 'CS'
                    when b.PRIMARY_UNIT_OF_MEASURE like '%Litro%' then 'Po'
                    when b.PRIMARY_UNIT_OF_MEASURE like '%Paquete%' then 'PACK'
                    when b.PRIMARY_UNIT_OF_MEASURE like '%Unidad%' then 'CS'
                    else 'CS'
            end as SELLING_UOM,
            null as MULTI_UNITS,
            null as MULTI_UNIT_RETAIL,
            null as MULTI_UNIT_RETAIL_CURRENCY,
            null as MULTI_SELLING_UOM,
            null as LOCK_VERSION
    from cmp_lineas_cotizacion l,
         inv.mtl_system_items_b b
    where b.segment1 || '.' || b.segment2 = l.cod_producto
          and (l.cod_producto in ((select codigo
                                 from tmp.viveres_vegetales)
                                 UNION
                                 (select codigo
                                 from tmp.genericos)
                                 UNION
                                 (select codigo
                                 from tmp.hijos_genericos)))
    and l.fec_ini_vigencia_precio > to_date('01/09/2008','DD/MM/YYYY')
          and (b.segment1 || '.' || b.segment2, l.fec_ini_vigencia_costo, l.mto_precio_venta) in
                          select lc.cod_producto, max(lc.fec_ini_vigencia_costo), max(lc.mto_precio_venta)
                          from  cmp_lineas_cotizacion lc
                          where lc.fec_ini_vigencia_precio > to_date('01/09/2008','DD/MM/YYYY')
                          group by lc.cod_producto
                          )

    Without table definitions, input data, and expected output, it's hard to test. But I would expect that analytic functions would be what you're after (assuming that omitting the "l.cod_producto in" clause from your main query in the subquery where you are getting the MAX values doesn't change any results). Something like
    SELECT <<all your columns>>,
           l.fec_ini_vigencia_costo,
           l.mto_precio_venta,
           max(l.fec_ini_vigencia_costo) over (partition by l.cod_producto) max_vigencia_costo,
           max(l.mto_precio_venta) over (partition by l.cod_producto) max_precio_venta
      FROM <<the rest of your query>>will include the MAX values and the current row values without needing to hit the table a second time. Then you should be able to do
    SELECT <<list of columns>>
      FROM (<<whole query from the last step>>)
    WHERE fec_ini_vigencia_costo = max_vigencia_costo
       AND mto_precio_venta = max_precio_ventaJustin

  • To create a Crystal Report which will prompt for a value and if nothing is entered select the alternative value from the database record.

    Hi Experts,
    I am working on a report in Crystal (2008) which will prompt user to input a value, but if nothing is entered then it will select relevant database value.
    I created a string parameter prompt called "{?Pack_Qty_Overide}" and used the following formula.
    IF {?Pack_Qty_Overide} = ""
    THEN {OITM.SalPackUn}
    ELSE {?Pack_Qty_Overide}
    However, when I check the formula in editor, it says that there should be a number at the end of "Else" clause.
    What am I doing wrong?

    Hi Janos,
    OITM.SalPackUn is Numeric(19.6). When I used parameter input type as number, my formula returned error that "A number is required here" at the "if .... " statement.
    So I used the formula you provided and it worked, such that when I input a quantity in parameter prompt it would display that, but if no override value given, the field remains blank - i.e. it does not display the value stored in OITM.SalPackUn.
    What am I doing wrong?
    Thanks,
    YP

  • How to find out the maximum value in a Query

    Dear all,
    Im creating a Query on 0SD_C03 where i have to disply Maximum value of a material..
    EX:
    MATERIAL BILLED VALUE
    x                   1000
    y                   3000
    z                   2500
    in a analyser i have to display only Y and 3000
    We are using BW 7.0 version
    Can any one help me out in this
    Thxs in Advance
    Venu

    Hi Venu,
    You may wish to refer the link below:
    http://help.sap.com/saphelp_nw04/helpdata/en/17/82853c2dc5c505e10000000a11405a/content.htm
    Assign points if this is helpful.
    Regards,
    Anil

  • Select the newest value of a row in a group by

    On the following query I would like to select the value of the column new_cost which belongs to the row with the newest date in the column m.creation_date, instead of using max(new_cost)
    select s.segment1, segment2, m.organization_id, sum(primary_quantity), max(new_cost)
    from inv.mtl_material_transactions m, inv.mtl_system_items_b s
    where s.segment2 = 1000435
    and m.organization_id = 83
    and s.organization_id = 136
    and m.inventory_item_id = s.inventory_item_id
    group by s.segment1, s.segment2, m.organization_id
    order by s.segment1, s.segment2, m.organization_id for example, on the following table I would like to choose the new_cost of the row with the creation date 20/08/2010 14:37 (row 4)
    SEGMENT1     SEGMENT2     ORGANIZATION_ID     PRIMARY_QUANTITY     NEW_COST     CREATION_DATE
    1     1000435     83     0,66668     175.500     04/06/2010 16:41
    1     1000435     83     1     189.106     22/06/2010 11:54
    1     1000435 83     -0,58333     189.106     19/07/2010 11:55
    1     1000435     83     1     198.459     20/08/2010 14:37
    1     1000435     83     -0,5     189.106     11/08/2010 18:12

    You should be able to use an analytic function... something similar to:
    with data
    as
         select 1 segment1, 1000435 segment2, 83 organization_id, 0.66668 primary_quantity, 175.500 new_cost, to_date('04/06/2010 16:41', 'DD/MM/YYYY HH24:MI:SS') creation_date
         from dual
         union all
         select 1 segment1, 1000435 segment2, 83 organization_id, 1 primary_quantity, 189.106 new_cost, to_date('22/06/2010 11:54', 'DD/MM/YYYY HH24:MI:SS') creation_date
         from dual
         union all
         select 1 segment1, 1000435 segment2, 83 organization_id, -0.58333 primary_quantity, 189.106 new_cost, to_date('19/07/2010 11:55', 'DD/MM/YYYY HH24:MI:SS') creation_date
         from dual
         union all
         select 1 segment1, 1000435 segment2, 83 organization_id, 1 primary_quantity, 198.459 new_cost, to_date('20/08/2010 14:37', 'DD/MM/YYYY HH24:MI:SS') creation_date
         from dual
         union all
         select 2 segment1, 1000435 segment2, 83 organization_id, -0.5 primary_quantity, 189.106 new_cost, to_date('11/08/2010 18:12', 'DD/MM/YYYY HH24:MI:SS') creation_date
         from dual
    select segment1, segment2, organization_id, primary_quantity_sum, new_cost
    from (
        select
              segment1,
              segment2,
              organization_id,
              sum(primary_quantity) over (
                   partition by
                        segment1,
                        segment2,
                        organization_id
              ) primary_quantity_sum,
              new_cost,
              row_number() over (
                   partition by
                        segment1,
                        segment2,
                        organization_id
                   order by
                        creation_date desc
              ) rn
        from data
        where segment2 = 1000435
    where rn = 1

  • How to find the maximum value among four fields in a single record

    Hi Gems...
    I have a record in which there are 4 currency fields.
    Now i would like to know the maximum of these 4 fields.
    I tried with Max functions in which i put all the 4 values...but it is showing error like ") is missing" though it is there.
    Can we insert more than 2 values in Max function?
    Or else is there any other option to find the max value among the 4 values which lies in a single record
    Thanks
    Jiten

    Hi Anil,
    Say suppose i have a single record in which 4 premiums of a particular bond exists.
    for eg:
    Prem1      Prem2        Prem3          Prem4
    129000.00      388000.00   228000.00   14800.00
    Now this is a single record for a particular bond ... now i need to calculate the max value among these 4 premiums.
    How would we proceed to achieve this?
    Regards
    Jiten
    Edited by: Jitendra Yuddandi on Feb 3, 2009 1:04 PM

Maybe you are looking for

  • How do i change the font back to lucida console in itunes 9?

    The font in itunes got messed up when I tried to change the screen resolution and now I don't know how to get it back to the default font which is Lucida Console. It's currently in Arial and I want to change it back to Lucida Console. Can someone ple

  • Introducing the Skype Community

    Welcome to the Skype Community After being in the air since early 2004 as Skype's Forum, since April 2008 as Skype's Community and now as the Skype Community it is about time to introduce the people with badges and those without who you see posting r

  • Windows edited/saved project crashing on  mac (adobe premiere cs5)

    hi there i really hope you can help. i have edited video files on adobe premiere cs5 on a windows 7 machine and saved the project ffiles on an external drive formy friend to colour grade and finalise etc he can open the video files in adobe premiere,

  • Adobe Flash Plug-in 10.1

    Hi, I know this post has been made loads of times and ive read them all but nothing's helped me. On my Mac PPC 10.4.11 Tiger, ive been trying to upgrade to the latest flash for powerpc 10.1. Ive followed all the innstruchtions of uninstalling and stu

  • Adobe does not show all titles on CD

    We put training modules on cd's and they open with Flash. All of a sudden i can see all the tiltles on the cd if i explore it but when Adobe opens it i only have one title in the slide title bar on the left.  I thought there was an edit location opti