Query - 3 rd maximum

Hi:
Am having a table names emp with column commission of numeric datatype. I need to find the 3 maximum commision from this emp table....
Thanks
Shan
[email protected]

Thanks alot Dr Clap, the thing is, i need an oracle query for the entire process to find third maximum. I dont want to use it with resultset after sorting it out in desc...Could you please suggest me a perfect oracle query that get me directly with this result of 3 maximum in comm column....(i guess subqueries too can be used..?)...
Regards
Shan

Similar Messages

  • DRG-11112: length of CLOB query value exceeds maximum of 64000

    Is there a CLOB length limitation when running an Oracle Text search? (v 11.1.0.7) I have checked the Reference Guide and Application Developer's Guide.
    --create table
    create table nk_1929(id number, vc_a clob);
    --insert dummy data
    declare
    vc_clob clob;
    begin
    vc_clob := lpad(to_clob('a'), 222920, 'a');
    insert into nk_1929 values(1, vc_clob);
    end;
    --create index
    create index nk_1929_ndx on nk_1929(vc_a)
    indextype is ctxsys.context parameters('
    datastore ctxsys.default_datastore
    stoplist ctxsys.empty_stoplist');
    --run query with a search string longer than 64000
    declare
    str1 clob;
    query_term clob;
    begin
    select vc_a into query_term from nk_1929 where id = 1;
    str1 := 'select id from nk_1929 where contains(vc_a, :1) > 0';
    execute immediate str1 using query_term;
    end;
    ORA-29902: error in executing ODCIIndexStart() routine
    ORA-20000: Oracle Text error:
    DRG-11112: length of CLOB Query Value exceeds maximum of 64000
    Please let me know if I am missing something here?

    Same 64000 CLOB query value limitation is also generated with a simple select:
    --run query with a search string longer than 64000
    declare
    vn_id number;
    query_term clob;
    begin
    select vc_a into query_term from nk_1929 where id = 1;
    select max(id) into vn_id from nk_1929 where contains(vc_a, query_term) > 0;
    end;
    ORA-29902: error in executing ODCIIndexStart() routine
    ORA-20000: Oracle Text error:
    DRG-11112: length of CLOB Query Value exceeds maximum of 64000

  • SQL query to select maximum

    Dear all,
    I have a table called "Orders" for a webshop that contains order ID, product ID, product quantity and price per unit. To insert a new order I want to get the highest order ID first and increase it by one, to be used as the new order ID.
    Here is the code:
    String orderIDquery = "SELECT MAX(OrderID) FROM Orders";
              int orderID = 0;
              try
                   rst = stm.executeQuery(orderIDquery);
                   if(rst == null)
                        orderID = 1;
                   else
                        rst.next();
                        orderID = rst.getInt("OrderID");
                        orderID++;
              catch(SQLException e)
                   out.println(e.toString());     
              out.println(orderID);For some reason, I get the SQL exception "column not found" from the "getInt" command, although the column by the name "OrderID" is clearly present in the table.
    Any ideas what could be wrong?
    TIA,
    NetWundi

    Dear all,
    I have a table called "Orders" for a webshop that
    contains order ID, product ID, product quantity and
    price per unit. To insert a new order I want to get
    the highest order ID first and increase it by one, to
    be used as the new order ID.
    Here is the code:
    String orderIDquery = "SELECT MAX(OrderID) FROM Orders";[snip]
    For some reason, I get the SQL exception "column not
    found" from the "getInt" command, although the column
    by the name "OrderID" is clearly present in the
    table.
    Any ideas what could be wrong?You don't have a column named "OrderID" in that Query. You can either refer to the column by number (1) or alias it in your sql and refer to it by the alias name (SELECT MAX(OrderID) AS SomeColumnName FROM Orders".
    Good Luck
    Lee
    >
    TIA,
    NetWundi

  • Bex Query: Too many table names in the query The maximum allowable is 256

    Hi Experts,
    I need your help, Im working on a Query using a multiprovider of 2 datastores, I need to work with cells to assign specific acconts values to specific rows and columns, so I was creating a Structure with elements from a Hierarchy, but I get this error when I'm half way of the structure:
    "Too many table names in the query. The maximum allowable is 256.Incorrect syntax near ')'.Incorrect syntax near 'O1'."
    Any idea what is happening? is ti possible to fix it? do I need to ask for a modification of my Infoproviders? Some one told me is possible to combine 2 querys, is it true?
    Thanks a lot for your time and pacience.

    Hi,
    The maximum allowable limit is 256 holds true. It is the max no. of characteristics and key figures that can be used in the column side. While creating a structure, you create key figures (restricted or calculated) and formulas etc.. The objects that you use to create these should not be more than 256.
    http://help.sap.com/saphelp_nw70/helpdata/EN/4d/e2bebb41da1d42917100471b364efa/frameset.htm
    Not sure if combination of 2 query's is possible.  You can use RRI. Or have a woorkbook with 2 queries.
    Hope it helps.

  • How to use dynamic query for Result table

    Hello Experts,
    I want to use dynamic query and then display the result in the assignment block.
    Using dynamic query BTQAct and BTQRAct and base on some search criteria i want tofilter and then append the result in the result table of that custom context node, and then it should display the result in the view in UI.
    SO can you please provide me the samplle code on how to use the dynamic query and append in the result table.
    Regards.

    Hi,
    Please find below sample code:
    data:  query         TYPE REF TO cl_crm_bol_dquery_service,
               result        TYPE REF TO if_bol_bo_col.
    DATA: lt_params       TYPE crmt_name_value_pair_tab,        
               lwa_params      TYPE crmt_name_value_pair.             
    query = cl_crm_bol_dquery_service=>get_instance( 'BTQAct' ). " Get instance of dynamic query
    Set general query parameter for maximum number of hits
          lwa_params-name = 'MAX_HITS' .
          lwa_params-value = '50'.
          APPEND lwa_params TO lt_params.
          query->set_query_parameters( it_parameters = lt_params ).
          query->add_selection_param( iv_attr_name = 'OBJECT_ID'
                                                    iv_sign      = 'I'
                                                    iv_option    = 'EQ'
                                                    iv_low       = <lv_objectid>
                                                    iv_high      = '' ). " Set your search criteria. Repeat this code if you have multiple parameters
    "You can find possible search options for a query object in  GENIL_BOL_BROWSER
    result ?= query->get_query_result(  ).   " Get result from your search query
    me->typed_context-> <your result context node>->set_collection( result ). 
    Here you will have to create a context node in your view which would refer to query result object like for BTQAct its BTQRAct                      
    Hope this helps.
    e Regards,
    Bhushan

  • 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 add extra per day records based on maximum occurances in the week.

    Hello,
    I need to add extra records based on maximum occurances on a day in a week.
    For example, the result of the query shows that maximum occuances in a week 0 is 3 on so I need to add empty records in each day in that week.
    SQL QUERY:
    with  numbers as (
    SELECT ROWNUM N FROM dual 
      CONNECT BY LEVEL <=35
    ),months as (
    SELECT     ADD_MONTHS('01-JUN-10',n-1) AS current_month,
         TO_CHAR(ADD_MONTHS('01-JUN-10',n-1),'fmMonth-YYYY') AS current_month_label
    FROM numbers
    WHERE ADD_MONTHS('01-JUN-10',n-1) <= NVL(add_months('01-JUN-10', :monthcount-1),:p_month)
    ORDER BY n ASC
    ) , dates as (
    select     trunc(trunc(m.current_month, 'MM'), 'D') + n - 1 calendar_date,
         trunc((n - 1) / 7) AS week_num,
                    m.current_month as current_month
    from     numbers, months m
    where trunc(dom.schedule.calendar_begin(m.current_month) + n - 1, 'd') <= last_day(m.current_month)
    Order By week_num, calendar_date
    select dates.week_num, edate, name from (
    --week 0
    select '30-MAY-10' as edate, 'JJ' as name from dual union
    select  '31-MAY-10' as edate, 'MK' as name from dual union
    select  '01-JUN-10' as edate, 'MK' as name from dual union
    select  '01-JUN-10' as edate, 'BK' as name from dual union
    select  '01-JUN-10' as edate, 'JJ' as name from dual union
    select  '04-JUN-10' as edate, 'KK' as name from dual union
    select  '04-JUN-10' as edate, 'LA' as name from dual      union
    -- week 1
    select  '06-JUN-10' as edate, 'BK' as name from dual union
    select  '06-JUN-10' as edate, 'JJ' as name from dual union
    select  '07-JUN-10' as edate, 'KK' as name from dual union
    select  '11-JUN-10' as edate, 'LA' as name from dual      
    ) a  join dates on dates.calendar_date = a.edate   
    order by week_num, to_date(edate);CURRENT RESULT :
    WEEK_NUM             EDATE                NAME
    0                   30-MAY-10            JJ
    0                   31-MAY-10             MK
    0                   01-JUN-10             MK
    0                   01-JUN-10             JJ
    0                   01-JUN-10             BK
    0                   04-JUN-10             KK
    0                   04-JUN-10             LA
    1                   06-JUN-10             BK
    1                   06-JUN-10             JJ
    1                   07-JUN-10             KK
    1                   11-JUN-10             LAREQUIRED RESULT:
    WEEK_NUM             EDATE                NAME
    0                   30-MAY-10             JJ
    0                   30-MAY-10            null
    0                   30-MAY-10            null
    0                   31-MAY-10            MK
    0                   31-MAY-10            null
    0                   31-MAY-10            null
    0                   01-JUN-10             BK
    0                   01-JUN-10              JJ
    0                   01-JUN-10             MK
    0                   02-JUN-10             null
    0                   02-JUN-10             null
    0                   02-JUN-10             null
    0                   03-JUN-10             null
    0                   03-JUN-10             null
    0                   03-JUN-10             null
    0                   04-JUN-10             KK
    0                   04-JUN-10             LA
    0                   04-JUN-10             null
    0                   05-JUN-10             null
    0                   05-JUN-10             null
    0                   05-JUN-10             null
    --Number of Week 1 records should be 14 = (max occurances on 06-JUN-10)  * 7
    1                   06-JUN-10             BK
    1                   06-JUN-10             JJ
    1                   07-JUN-10             KK
    1                   07-JUN-10             null
    1                   08-JUN-10             null
    1                   08-JUN-10             null
    1                   09-JUN-10             null
    1                   09-JUN-10             null
    1                   10-JUN-10             null
    1                   10-JUN-10             null
    1                   11-JUN-10             LA
    1                   11-JUN-10             null
    1                   12-JUN-10             null
    1                   12-JUN-10             nullI would appreciate it if you could help me to find efficient way to achieve this?
    Thanks,
    GM
    Edited by: user12068331 on Sep 28, 2010 2:17 PM
    Edited by: user12068331 on Sep 28, 2010 2:48 PM

    Ok,
    Few things to clarify first :
    1 - How do you define week number ?
    Oracle has 2 different way for week number : normal week number (WW) and isoweek (IW).
    is your weeknumber one of those, or is it something else ?
    2 - Depending on the country the week doesn't start on the same day : in France (as most of Europe I think) first day is monday, where in the USA (as far as I know) first day is sunday.
    the to_char builtin function can display weeknumber :with a as (
    --week 0
    select 0 as weeknum, to_date('30-MAY-2010','DD-MON-YYYY') as edate, 'JJ' as name from dual union all
    select 0 as weeknum, to_date('31-MAY-2010','DD-MON-YYYY') as edate, 'MK' as name from dual union all
    select 0 as weeknum, to_date('01-JUN-2010','DD-MON-YYYY') as edate, 'MK' as name from dual union all
    select 0 as weeknum, to_date('01-JUN-2010','DD-MON-YYYY') as edate, 'BK' as name from dual union all
    select 0 as weeknum, to_date('01-JUN-2010','DD-MON-YYYY') as edate, 'JJ' as name from dual union all
    select 0 as weeknum, to_date('04-JUN-2010','DD-MON-YYYY') as edate, 'KK' as name from dual union all
    select 0 as weeknum, to_date('04-JUN-2010','DD-MON-YYYY') as edate, 'LA' as name from dual union all
    -- week 1
    select 1 as weeknum, to_date('06-JUN-2010','DD-MON-YYYY') as edate, 'BK' as name from dual union all
    select 1 as weeknum, to_date('06-JUN-2010','DD-MON-YYYY') as edate, 'JJ' as name from dual union all
    select 1 as weeknum, to_date('07-JUN-2010','DD-MON-YYYY') as edate, 'KK' as name from dual union all
    select 1 as weeknum, to_date('11-JUN-2010','DD-MON-YYYY') as edate, 'LA' as name from dual
    select to_char(a.edate,'IW') isoweek, to_char(a.edate,'WW') numweek, a.*
    from a;
    IS NU    WEEKNUM EDATE                          NA
    21 22          0 Sunday    30/05/2010 00:00:00  JJ
    22 22          0 Monday    31/05/2010 00:00:00  MK
    22 22          0 Tuesday   01/06/2010 00:00:00  MK
    22 22          0 Tuesday   01/06/2010 00:00:00  BK
    22 22          0 Tuesday   01/06/2010 00:00:00  JJ
    22 23          0 Friday    04/06/2010 00:00:00  KK
    22 23          0 Friday    04/06/2010 00:00:00  LA
    22 23          1 Sunday    06/06/2010 00:00:00  BK
    22 23          1 Sunday    06/06/2010 00:00:00  JJ
    23 23          1 Monday    07/06/2010 00:00:00  KK
    23 24          1 Friday    11/06/2010 00:00:00  LA
    11 rows selected.

  • Finding maximum Date in Cube

    Hi,
    How can I find the Maximum date from all the dates of a date characterstic which exists in CUBE Data.
    I want restrict a selection in my Query with this maximum Date. So how can i fetch that date into a variable?

    Hi
    You can call the function module RSDRI_INFOPROV_READ in your exit for the variable and read the dates and find the maximum. You have to pass the name of the info cube u want to read. However writing this code is slightly a tedious job. So think of any other way u can meet ur requirement.
    If you want to use the function module tell me i ll send u a piece of code which will give you an idea.
    Thanks
    Mansi

  • Kill query on forms? Possible?

    I have inherited a forms application, when it was developed 10 years ago having a select * from table_name on all tables was fine.
    Now I have a form that still allows a full table scan- but now the table has over 200 million records. What would be the easiest way to stop a full table scan on this form? I am running forms 6i on a linux x86 platform. I was thinking to create an alert- but I can't get it to kill the query.
    I am new to forms- because I have inherited this application.
    Hitting cancel query- which exectues a KILL_FORM doesn't work- it hangs the form and the query still is active when I query v$session, v$process.
    Sorry, to bother you, but I would like to get a good feel of which avenue to look at before I invest research time.

    "Would maximum query time, or maximum records fetched work?"
    The on-line help points out for this property
    "Specifies the interaction mode for the form module. Interaction mode dictates
    how a user can interact with a form during a query. If Interaction Mode is set to
    Blocking, then users are prevented from resizing or otherwise interacting with the
    form until the records for a query are fetched from the database. If set to Non-
    Blocking, then end users can interact with the form while records are being
    fetched.
    Non-blocking interaction mode is useful if you expect the query will be
    time-consuming and you want the user to be able to interrupt or cancel the query.
    In this mode, the Forms runtime will display a dialog that allows the user to
    cancel the query. "
    Greetings...
    Sim

  • Maximum number of columns allowed in LOV

    I have some technical doubts
    1)What is the maximum number a lov allows?
    2)Maximum length of record group query?
    3)Maximum number of items assigned using LOV?
    Please reply immediate
    Thanks in advance
    Manoj M

    I have some technical doubts
    1)What is the maximum number a lov allows?i doubt for this it also takes 20 values as per my knowledge in oracle apps
    2)Maximum length of record group query?a meaningful query in record group up to unlimited extent will be accepted
    3)Maximum number of items assigned using LOV? by taking a parameter you can assign the same lov to different items
    >
    Please reply immediate
    Thanks in advance
    Manoj M

  • Maximum Connections Oracle can provide

    I have this query, how many maximum connections does oracle provide to any applications server.
    I am aware that the number of connections are configurable. But i wanted to know the maximum number of connections after which there is a possibilty of oracle to crash, or after these particular number connectins oracle wont support any more connections.
    Please help me with this, as im in desperate need of a solution.
    Thanx for your time.
    Nikhil

    There is no functional limit to the number of connections Oracle can support. There may be some internal limit (i.e. session ID may be an integer, which would limit you to 4 billion connections on a 32-bit system) but I've never heard of anyone actually hitting such a limit. In reality, you will be constrained by your hardware long before you are constrained by Oracle.
    Unfortunately, estimating how many connections your particular hardware can support is not trivial. It depends, obviously, on your hardware, but it also depends on your application and on how your database is configured-- shared server vs. dedicated server would be the largest factor here.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Maximum Conncetions Oracle can provide

    I have this query, how many maximum connections does oracle provide to any applications server.
    I am aware that the number of connections are configurable. But i wanted to know the maximum number of connections after which there is a possibilty of oracle to crash, or after these particular number connectins oracle wont support any more connections.
    Please help me with this, as im in desperate need of a solution.

    There is no functional limit to the number of connections Oracle can support. There may be some internal limit (i.e. session ID may be an integer, which would limit you to 4 billion connections on a 32-bit system) but I've never heard of anyone actually hitting such a limit. In reality, you will be constrained by your hardware long before you are constrained by Oracle.
    Unfortunately, estimating how many connections your particular hardware can support is not trivial. It depends, obviously, on your hardware, but it also depends on your application and on how your database is configured-- shared server vs. dedicated server would be the largest factor here.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Max no columns allowed in a table

    i want to know how many columns are allowed in a table.maximum no of columns in table.

    I hope this will be helpful for query
    ORA-01792: maximum number of columns in a table or view is 1000
    Cause: An attempt was made to create a table or view with more than 1000 columns, or to add more columns to a table or view which pushes it over the maximum allowable limit of 1000. Note that unused columns in the table are counted toward the 1000 column limit.
    Action: If the error is a result of a CREATE command, then reduce the number of columns in the command and resubmit. If the error is a result of an ALTER TABLE command, then there are two options: 1) If the table contained unused columns, remove them by executing ALTER TABLE DROP UNUSED COLUMNS before adding new columns; 2) Reduce the number of columns in the command and resubmit.

  • How to display all available data for KFs from different Cubes

    Hi,
    I am using a MultiProvider that consists of two InfoCubes. KF1 uses Cube1, KF2 uses Cube2 - characteristic Country exists in both cubes. I have the following data:
    KF1 - Country 1: 5
    KF1 - Country 3: 8
    KF1 - Country 4: 10
    KF2 - Coutnry 1: 9
    KF2 - Country 2: 7
    KF2 - Country 5: 3
    I have a query that uses Country as a drilldown characteristic (ROWS) and displays the values of KF1 and KF2 (COLUMNS) for each Country. However, instead of seeing data for Countries 1-5 I only see data where I have results for KF1 (Countries 1,3 and 4). The value for Country 1 for KF2 shows up correctly in the corresponding row, but Countries 2+5 aren't displayed for KF2. If I change the Access Type for Result Values from "Posted Values" to "Master Data" I get the correct result. However this is not feasible in the final setting due to the amount of data that has to be handled (MasterData setting will lead to crashes of the query due to maximum number of cells exceeded).
    Are there any other options to force the query to display values for all characteristic values where I have data for any KF?
    Thanks a lot for your help!
    Best regards,
    David

    As it turned out the issue was due to 2 restrictions on KPI2:
    1) Restriction to InfoProvider "Cube 2"
    2) Constant selection on two characteristics that have filters on a global level but which should not affect the display of the data for KF2
    Removing (1)+(2) provided the desired result.

  • SQLs erver migration performance issue

    We are performing migration from oracle to MSSQL server 2005 (Windows 2003/SAP 4.6D).Our target system configuration is like below:
    ->OS - Windows 2003 x64
    ->DB - MSSQL server 2005 SP4
    ->SAP - 4.6 D kernel
    ->CPU - 4 processors (2.67ghz each)
    ->RAM - 16 GB
    ->source system DB size - around 1 TB and package splitting was implemented.
    While importing the export dump that came from source system, we are facing load performance issue's.
    1) We have started 10 parallel processes and after import is started, CPU is getting 95% to 99% utilized and when we check SQL server studio-> Activity monitor we  found below information:
    -There were around 20 processes are in status sleeping
    -Only one or two system processes are running with commands - INSERT,SELECT INTO commands ( column)
    -At any point of time only two processes are running and CPU utilization is hitting high.
    -Import is very slow and its taking 35 hours to complete
    We have followed few SAP notes(1054852,1241751 e.tc..) and below are the settings for SQL server:
    -Minimum server memory - 5 GB
    - Maximum server memory - 5 GB
    - index creation memory - 0
    - Maximum memory per query - 1024 kb
    - Maximum degree of parellelism - 1
    - Parallellism locks - 0
    - Cost threshold of parellism - 5
    - Enabled trace flags - 610,620,1117,1211,3917
    - Windows environment variable BCP_BATCH_SIZE = 10000
    - SQL log file size - 100 GB
    - tempdb size - 20 GB
    2) When we tried another test import after tuning parameters (Maximum degree of parellelism to 3) and increasing r3load parallel processes to 20, we found  of inserts
    are overflowing in process list and blocking other waiting processes and putting them in suspended mode.CPU utilization is at 80%
    Are there any SQL server parameters need to be tuned to fix this import load time issue in both scenarios? Are there any  best practises for migrating to SQL server?
    Thanks..

    > 1) We have started 10 parallel processes and after import is started, CPU is getting 95% to 99% utilized and when we check SQL server studio-> Activity monitor we  found below information:
    What processes is using the CPU? The SQL Server itself or others? (see task manager)
    > -Minimum server memory - 5 GB
    > - Maximum server memory - 5 GB
    For the time of the migration itself I'd give the database more memory (10 GB or more) and reconfigure later when the import is done.
    What parameters do you use for the R3load? I'd recommend
    -loadprocedure fast -merge_bck -c 10000
    and also set
    BCP_LOB=1 in the environment.
    Markus

Maybe you are looking for

  • Update kernel and recieved a "Machine check error"

    I was on Vacation this last weekend but was finally able to update today. Upgrade seemd fine, issued reboot command and instead of my normal reboot I was greeted with "machine check error" flashing in my upper left hand corner. Syslinux never came up

  • User exit to check/uncheck the GR Indicator at the time of PO creation

    Hi, Can anybody help me out in finding the right user exit/BAdi to control the GR Indicator flag. We already tried the user exits: EXIT_SAPLMEKO_001 EXIT_SAPLMEKO_002 EXIT_SAPLFYTX_USER_001 EXIT_SAPMM06E_012 EXIT_SAPMM06E_013 EXIT_SAPMM06E_009 and al

  • File adapter error, because the filename contains "u00D1"

    Hi, I'm working in a spanish project, I've an interface FTP --> PI --> IDOC, my problem is because in spanish the letter "Ñ" is used and when there are one file in the folder with this letter the communication channel fails because the communication

  • RS232-to-USB converter

    I have an electronic which is connected to either RS-232 serial or USB. Since the electronic cable has a RS-232 adapter, I have to use RS232-to-USB converter to make it compatible with USB port. My LabView application runs well with RS-232 port but d

  • Quicktimes taking very long time to load-Big Q appears instead.

    When posting ipod (small) quicktimes to my .mac account (4 per page), the site is taking a really long time to load-a large Q appears instead of the usual Quicktime video frame for a few minutes. They eventually load, but it takes a long time. I've u