SELECT TOP 1 .... ORDER BY

Hi,
I have the following statement in SQL SERVER:
SELECT TOP 1 NAME FROM STUDENT ORDER BYGRADE
Now, I am trying to translate it ti ORACLE PLSQL, I came up with this statement:
SELECT NAME FROM STUDENT WHERE ROWNUM=1 ORDER BY GRADE
It doesn't work. I guess ORACLE generates ROWNUM before the ORDER BY operation...
How can I have SELECT TOP N ... ORDER BY ... in Oracle the way that I have it in SQL server?
Any help would be apprecited,
Alan

Can you cut and paste exactly what you're doing in a SQL*Plus session? It seems to work for me
SCOTT @ hp92 Local> create table t as select * from all_objects;
Table created.
Elapsed: 00:00:08.40
SCOTT @ hp92 Local> desc t;
Name                                                  Null?    Type
OWNER                                                 NOT NULL VARCHAR2(30)
OBJECT_NAME                                           NOT NULL VARCHAR2(30)
SUBOBJECT_NAME                                                 VARCHAR2(30)
OBJECT_ID                                             NOT NULL NUMBER
DATA_OBJECT_ID                                                 NUMBER
OBJECT_TYPE                                                    VARCHAR2(18)
CREATED                                               NOT NULL DATE
LAST_DDL_TIME                                         NOT NULL DATE
TIMESTAMP                                                      VARCHAR2(19)
STATUS                                                         VARCHAR2(7)
TEMPORARY                                                      VARCHAR2(1)
GENERATED                                                      VARCHAR2(1)
SECONDARY                                                      VARCHAR2(1)
SCOTT @ hp92 Local> create index idx_t on t( object_id );
Index created.
Elapsed: 00:00:00.78
SCOTT @ hp92 Local> analyze table t compute statistics for all indexed columns;
Table analyzed.
Elapsed: 00:00:00.53
SCOTT @ hp92 Local> set autotrace on;
SCOTT @ hp92 Local> select *
  2    from (select * from t order by object_id)
  3   where rownum < 2;
OWNER                          OBJECT_NAME                    SUBOBJECT_NAME
OBJECT_ID DATA_OBJECT_ID OBJECT_TYPE        CREATED   LAST_DDL_ TIMESTAMP           STATUS  T G S
SYS                            DUAL
       222            222 TABLE              12-MAY-02 12-MAY-02 2002-05-12:16:20:50 VALID   N N N
Elapsed: 00:00:00.13
Execution Plan
   0      SELECT STATEMENT Optimizer=CHOOSE
   1    0   COUNT (STOPKEY)
   2    1     VIEW
   3    2       TABLE ACCESS (BY INDEX ROWID) OF 'T'
   4    3         INDEX (FULL SCAN) OF 'IDX_T' (NON-UNIQUE)
Statistics
          0  recursive calls
          0  db block gets
          3  consistent gets
          1  physical reads
          0  redo size
       1142  bytes sent via SQL*Net to client
        511  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processedJustin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

Similar Messages

  • How to select top one in CDS view ?

    I have tried following logic to select top one in CDS view but its giving error -
    define view Cds_View_First_Reference as select  top one CReferredObject from CDSVIEWCROSSREF

    Hi Ruchi,
    since you posted this question in "ABAP in Eclipse" I assume you are asking about CDS in ABAP. This is important because the CDS features sets in ABAP and (native) HANA are different.
    Be that as it may,, SELECT TOP 1 is neither supported in the CDS implementation in ABAP nor in HANA.
    In ABAP you might consider using the min() or max() function together with the appropriate GROUP BY clause in the CDS view (depending on what you want to achieve), but you can also easily "implement" this in the Open SQL statement which selects from your CDS view.
    Using the additions SELECT SINGLE or UP TO 1 ROWS and an appropriate ORDER BY clause in Open SQL, you can achieve the same as SELECT TOP 1.
    Unfortunately there is currently no possibility to define a view which delivers the TOP 1 which you can again use in another view ("view on view").
    Kind regards
    Chris

  • Prepared Statement, executing  SELECT TOP in Ms Access

    I'm having the following problem. I built an application fetching data without any problem from MS SQL Server, this was using prepared statements. Now i'm having this strange problem with the following query:
    SELECT TOP 1 *
    FROM table
    WHERE appliance_id = ?
    AND ttimestamp_initpk <= ?
    AND ((Type = ?) OR (Type = ?) OR (Type = ?) OR (Type = ?) OR (Type = ?) OR (Type = ?))
    ORDER BY ttimestamp_initpk DESC
    While on SQL Server this fetches just a record, on MS Access it fetches the whole set of records without worrying about TOP instruction.
    That is, it acts like a SELECT * FROM, and this slows down runtime behaviour.
    I'm using sun.jdbc.odbc.JdbcOdbcDriver, is it the problem?
    Thanks, Mirko

    Thanks for your answer, but i'm not sure this is the reason.
    I made one more test: i wrote a .Net application connecting to a MS Access using an ODBC connection. SELECT TOP statement is working fine, so i think i'll try another JDBC driver. Any other solution??
    Thanks,
    Mirko

  • Group By Select Top 1 Rows

    Hi Guys,
    I tried Group By from Select Top 1 Records,  As below the script wasn't work.
    Please help.
    SELECT TOP 1 NR.SHGId, NR.Amount
    FROM NEW_DCB_REPORT NR
    WHERE NR.SHGId = ND.SHGId
    AND NR.ShgMemberId = ND.ShgMemberId 
    AND NR.LoanNumber = ND.LoanNumber 
    GROUP BY NR.SHGId,NR.Amount
    ORDER BY NR.LedgerNumber DESC
    SHGId
    SHGMemberId
    LoanNumber
    Amount
    Select Top 1 Row
    1028
    147852
    1
    1000
    Select Top 1 Row
    1028
    147853
    1
    2000
    Select Top 1 Row
    1028
    147854
    1
    1000
    Select Top 1 Row
    1028
    147855
    1
    1000
    5000
    I expected the results are:
    SHGId
    Amount
    1028
    5000

    Yes I did it.
    Select  SHGId,
    SUM(Amount)
    amt  FROM
    SELECT  NR.SHGId,
    NR.Amount,
    , Row_number()
    Over(partition
    by NR.SHGId,
    NR.ShgMemberId , NR.LoanNumber
    Order
    by NR.LedgerNumber
    DESC
    ) rn
    FROM NEW_DCB_REPORT NR
    JOIN
     NEW_DCB_REPORT ND
    ON
    NR.SHGId
    =
    ND.SHGId
    AND NR.ShgMemberId
    = ND.ShgMemberId
    AND NR.LoanNumber
    = ND.LoanNumber
    ) t
    Where rn=1
    GROUP
    BY  SHGId
    I just changed above the script Partition by add one more column and
    [yourNDTable]
    Should come NEW_DCB_REPORT table.
    However, It shows below the error ,. Please help.
    Invalid object name 'NEW_DCB_REPORT'.

  • Can SELECT TOP have argument?

    Newbie’s question, I believe.
    I wanted to make a stored procedure to returns last several rows or last several hundred rows depending on the situation, so I started writing queries in order to copy/paste them into procedure. There are two queries, first works, but
    second one shows syntax error in select statement. Can anyone tell me why, and how to go around this?
    SELECT TOP 5 * FROM Table1 ORDER BY ID DESC
    DECLARE @Counter as int
    SET @ Counter = 5
    SELECT TOP @ Counter FROM Table1 ORDER BY ID DESC

    This works. But I still don?t realize what was wrong with my syntax. Do those () will convert what?s inside parameter to string so parser could read it correctly? What actually is going on here?
    It's just the way it is. Originally there was only SELECT TOP n, where the value after TOP had to be a constant. Then they added the ability to have expression, but then they added the parens. This is so that you can say things like:
    SELECT TOP (SELECT ... FROM ...) ... FROM
    if you feel like.
    The old syntax is deprecated but remains for compatibility reasons.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Oracle 10g Select Top 100 Percent

    Hello
    How to convert MS sql 2008 select top 100 query Oracle PL/SQL ? MY sample MSSQL select query
    SELECT TOP (100) PERCENT dbo.Operations.OpID, dbo.CompanyInfo.Name AS CompanyName, dbo.CustomerInfo.SubscriberNo, dbo.CustomerInfo.FirstName,
    dbo.CustomerInfo.LastName, dbo.Operations.OpDate, dbo.Operations.BillCount, dbo.Operations.TotalAcceptedCash, dbo.Operations.KioskID,
    dbo.Operations.ReceiptNo, dbo.Operations.KioskOpID, dbo.KioskInfo.Name AS KioskName, dbo.Operations.TotalBill, dbo.Operations.TotalPayBack,
    dbo.CompanyInfo.CompanyID, dbo.Operations.ConfirmedRecord, dbo.PayMethod.ACK AS PayMethod
    FROM dbo.Operations INNER JOIN
    dbo.CustomerInfo ON dbo.Operations.SubscriberNo = dbo.CustomerInfo.SubscriberNo INNER JOIN
    dbo.CompanyInfo ON dbo.Operations.CompanyID = dbo.CompanyInfo.CompanyID INNER JOIN
    dbo.KioskInfo ON dbo.Operations.KioskID = dbo.KioskInfo.KioskID INNER JOIN
    dbo.PayMethod ON dbo.Operations.PayMethodID = dbo.PayMethod.PayMethodID
    ORDER BY dbo.Operations.OpDate DESC

    Hi,
    Please read SQL and PL/SQL FAQ
    Additionally when you put some code please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    From what I have found on MS SQL documentation it seems that TOP keyword limits the output to a specified percentage of total number of rows. In your case, having specified 100, you are returning 100% of rows.
    So you can simply remove *TOP (100) PERCENT*
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Select Top 10 when it includes a GroupBy

    I frequently use Select Top 10... to test a query before running it on a large MSSQL database. Works fine, except when the query includes a Group By Clause when it then seems to take as long as not using Top 10. I suspect this is beause it is actually
    reading the whole table to get the top 10 Group Bys, whereas all I wanted was for it  read the first 10 records and Group the result. Is there a way to write so that it does that                                                                                                                                
    Gerry Mescal

    sample code ..modify and try this SELECT a.*
    FROM
    SELECT a.*, ROW_NUMBER() OVER(PARTITION BY m.[col1] ORDER BY m.[col2] DESC) an
    FROM [table] a
    ) a
    WHERE a.an <= 10
    ORDER BY m.[col2] DESCmark as answer if it is useful

  • Selecting top five rows

    hi,
    pls I have this issue that needs to be resolved. I need to select top five rows from a table depending on the values of a column stock_value. pls I will appreciate if someone can help me out, Francois pls try and help
    This is the senerio:
    I have a table stock, on the table I have company_name, stock_value, sector.
    Now I want to get top five rows from this table depending on the five highest value of stock_value and for each sector.
    lets try and write a query that will retrive the records after that I will put it in a procedure.
    I know am suppose to ask this on mssql forum but most mssql forums takes time to reply and this is very urgent cos I have to deliver in 45 minutes time
    thank you very much
    jideofor

    hy,
    try out:
    select s.name, sp. sp_sales total_sales
    from salesperson s,
    (select salesperson_id,sum(tot_sales) sp_sales
    RANK() OVER (ORDER BY SUM(tot_SALES) desc) SALES_RANK
    FROM ORDERS
    WHERE YEAR = 2006
    group by salesperson_id) sp
    where sp.sales_rank <= 5 (...n)
    and sp.salesperson_id = s.salesperson_id
    order by sq.sales_rank;
    give result in:
    name total_sales
    a 100
    b 90
    c 80
    d 70
    e 60
    hope help you
    regards

  • Select top 10 percentage

    Hi,
    I want to get the top 10% of salaries in employees table. But I got error:
    SQL> select top 10 percent salary
      2  from employees
      3  order by salary desc;
    ORA-00923: FROM keyword not found where expectedHow can I get the top 10% percent?
    Thanks a lot

    Hi,
    998093 wrote:
    ... What if I want to get, for example, the employees who are in the top 12% of the salaries? here we cannot use deciles (maybe we can but it won't be very nice).Actually, you can. How nice it will be depends on your data and your exact requirements.
    Earlier, we said that the top 10% was the 10th of 10 buckets.
    We could say that the top 12% is the last 12 of 100 buckets:
    WITH     got_tenth     AS
         SELECT     last_name, salary
         ,     NTILE (100) OVER (ORDER BY salary)     AS hundredth
         FROM     hr.employees
    SELECT       last_name, salary
    FROM       got_tenth
    WHERE       hundredth     > 100 - 12
    ORDER BY  salary     DESC
    ;I won't clutter up this message by showing the results for every query; I'll just report the total number of rows. The query I posted earlier (for the top 10%) produced 10 rows of output; the query immediately above produces 12. That's starting to bother me. There are 107 rows in hr.employees. (They all have a salary; don't forget to deal with NULLs in general.) The top 10% should contain 107 * .1 = 10.7 rows. Of course, this has to be rounded to an integer, so it would have been a little better if the top 10% showed 11 rows (since 11 is closer to 10.7 than 10 is), but it's not a real big problem. Likewise, the top 12% should have 107 * .12 = 12.84 rows, so 13 rows of output might be better, but 12 rows isn't too bad.
    Now say we want to simplify the condition "WHERE     hundredth     > 100 - 12". Instead of taking the last 12 buckets in ascending order, let's take the first 12 buckets in descending order:
    WITH     got_tenth     AS
         SELECT     last_name, salary
         ,     NTILE (100) OVER (ORDER BY salary DESC)     AS hundredth
         FROM     hr.employees
    SELECT       last_name, salary
    FROM       got_tenth
    WHERE       hundredth     <= 12
    ORDER BY  salary     DESC
    ;The result set now contains 19 rows! Why? Because NTILE puts extra items (when there are extras) in the lower-numbered buckets. When there were 10 buckets, then buckets 1 trough 7 had 11 items each, and buckets 8 through 10 had 10 items. We were only dispolaying bucket #10, so we only saw 10 items. Now that there are 100 buckets, buckets 1 through 7 will have 2 items each, and buckets 8 through 100 will have 1 item each. When we numbered the buckets in ascending order, and took the last 12 buckets, we wound up with 12 * 1 = 12 rows, but when we numbered the buckets in descending order and took the first 12 buckets, we got (7 * 2) + (5 * 1) = 19 rows.
    When you have R rows and B buckets, and R/B doesn't happen to be an integer, then NTILE will distribute the rows as equally as possible, but some rows will have 1 item more than others. When the ratio R/B is high, that might not be very significant, but when R/B gets close to 1, then you have situations like the one above, where the bigger buckets, although they have only 1 more item than the smaller buckets, are twice as big. Even worse is the situation where R/B is less than 1; then the last buckets will have 0 items.
    So, as you noticed, NTILE isn't a good solution for all occasions. Here's a more accurate way, using the analytic ROW_NUMBER and COUNT functions:
    WITH     got_analytics     AS
         SELECT     last_name, salary
         ,     ROW_NUMBER () OVER (ORDER BY  salary  DESC)     AS r_num
         ,     COUNT (*)     OVER ()                                AS n_rows
         FROM     hr.employees
    SELECT       last_name, salary
    FROM       got_analytics
    WHERE       r_num / n_rows <= 12 / 100
    ORDER BY  salary     DESC
    ;This produces 12 rows.
    If you want 13 rows (because 107 * .12 = 12.84 is closer to 13), then you can change the main WHERE clause like this:
    WITH     got_analytics     AS
         SELECT     last_name, salary
         ,     ROW_NUMBER () OVER (ORDER BY  salary  DESC)     AS r_num
         ,     COUNT (*)     OVER ()                                AS n_rows
         FROM     hr.employees
    SELECT       last_name, salary
    FROM       got_analytics
    WHERE       r_num     <= ROUND (n_rows * 12 / 100)
    ORDER BY  salary     DESC
    ;

  • Convert "select top 5 ..." in Oracle8i

    -- We are in the process of migrating application from SQLserver7 to Oracle8i,
    -- and trying to convert a procedure to return top 5
    -- rows given a search string.
    -- In SQLserver7, "select top 5 ... "
    -- The Oracle8i Application Developer's Guide - Fundamentals
    -- recommends to use rownum, the query runs OK in SQL*Plus,
    -- but gets error when used in a procedure with returned cursor.
    -- Is there any solution for it?
    -- Following is the sample query and procedure (in a package)
    -- Query returns top 5 rows
    select t.rank, t.productid, t.productname
    from (
    Select score(0) as rank, productid, productname
    from Product
    where status = 'A'
    and contains(productname, 'Frog', 0) > 0
    order by rank desc, productid
    ) t
    where rownum < 6;
    -- Proc Name: Pr_Test
    -- Purpose: Retrieve product data for a specified search string
    CREATE OR REPLACE PACKAGE pkg_test
    IS
    TYPE RT1 IS RECORD (
    Rank NUMBER(10),
    ProductID Product.ProductID%TYPE,
    ProductName Product.ProductName%TYPE
    TYPE RCT1 IS REF CURSOR RETURN RT1;
    PROCEDURE pr_test
    (i_searchstring IN VARCHAR2 ,
    io_prdcursor IN OUT RCT1);
    END pkg_test;
    CREATE OR REPLACE PACKAGE BODY pkg_test
    AS
    PROCEDURE pr_test
    (i_searchstring IN VARCHAR2 ,
    io_prdcursor IN OUT RCT1)
    IS
    BEGIN
    OPEN io_prdcursor FOR
    select t.rank, t.productid, t.productname
    from (
    Select score(0) as rank, productid, productname
    from Product
    where status = 'A'
    and contains(productname, i_searchstring, 0) > 0
    order by rank desc, productid
    ) t
    where rownum < 6;
    END pr_test;
    END pkg_test;
    -- Following is the error message when compiling the package body:
    Warning: Package Body created with compilation errors.
    SQL> show error
    Errors for PACKAGE BODY PKG_TEST:
    LINE/COL ERROR
    19/7 PLS-00103: Encountered the symbol "ORDER" when expecting one of
    the following:
    ) * & - + / mod rem with an exponent (**) and or group having
    intersect minus start union where connect &#0124; &#0124;
    The symbol ")" was substituted for "ORDER" to continue.
    20/11 PLS-00103: Encountered the symbol ")" when expecting one of the
    following:
    . ( , * @ % & - + ; / for mod rem an exponent (**) asc desc
    &#0124; &#0124;
    -- Run the procedure and get the results
    declare
    i number := 0;
    v_string varchar2(50) := 'CAT';
    -- v_string varchar2(50) := 'FROG%';
    v_RC1 pkg_test.RCT1;
    v_Score NUMBER(10);
    v_ProductID Product.ProductID%TYPE;
    v_ProductName Product.ProductName%TYPE;
    begin
    pkg_test.pr_test (v_string, v_RC1);
    LOOP
    FETCH v_RC1 INTO v_Score,v_ProductID,v_ProductName;
    EXIT WHEN (v_RC1%NOTFOUND);
    DBMS_OUTPUT.put_line(substr('Score='&#0124; &#0124;v_score&#0124; &#0124;', ProdID='&#0124; &#0124;v_ProductID ,1,255));
    i := i + 1;
    END LOOP;
    DBMS_OUTPUT.put_line('Total '&#0124; &#0124;i&#0124; &#0124;' records retrieved.');
    end;
    null

    http://www.orafaq.org/faqsql.htm#TOP
    This may be of use, the plsql cursor declaration syntax may not have all the facilities of runnning the query from sqlplus:
    How does one select the TOP N rows from a table?
    Form Oracle8i one can have an inner-query with an ORDER BY clause. Look at this example:
    SELECT *
    FROM (SELECT * FROM my_table ORDER BY col_name_1 DESC)
    WHERE ROWNUM < 10;
    Use this workaround with prior releases:
    SELECT *
    FROM my_table a
    WHERE 10 >= (SELECT COUNT(DISTINCT maxcol)
    FROM my_table b
    WHERE b.maxcol >= a.maxcol)
    ORDER BY maxcol DESC;
    Turloch

  • Selecting TOP 20 Products per Catagory

    Hi
    I'm trying to select the TOP 20 Products per Catagory out of my Star Topology Database
    if someone would PLEASE be able to help me out.
    Here is my Query: -
    SELECT Distinct (SELECT TOP 20 DP.[Description]), DP.Mims_Sub_Cat, SUM(FD.Cost) AS 'Cost'
    FROM DIM_Product DP, FACT_Dispensary FD, DIM_Time DT, DIM_Client DC
    WHERE DP.Product_KEY = FD.Product_Key
    AND FD.Time_KEY = DT.Time_KEY
    AND FD.Client_Key = DC.Client_KEY
    AND DT.[Year] = 2007
    AND DT.[Month] IN (2)
    AND Client_name LIKE '%Medicare%'
    AND DP.Manufacture_Name LIKE '%Cipla%'
    --AND DP.[Description] IN (SELECT TOP 20 [Description])
    AND DP.Mims_Sub_Cat IN (SELECT Mims_Sub_Cat)
    GROUP BY DP.Mims_Sub_Cat, DP.[Description], FD.Cost
    ORDER by DP.Mims_Sub_Cat, SUM(FD.Cost) DESC
    My other problem is that it keeps on selecting the same products although i have a distinct in my query
    The query will select a product with the amount and then select the same product again with a different amount.
     Example :-
    Product Descripion               Catagory              Cost
    ULTAK TABS 150MG 60    Acid Reducers    384.94
    ULTAK TABS 150MG 60    Acid Reducers    85.54
    ULTAK TABS 150MG 60    Acid Reducers    56.98

    What about:
    SELECT * FROM
    SELECT DP.[Description], DP.Mims_Sub_Cat, SUM(FD.Cost) AS 'Cost',
    RANK() OVER(PARTITION BY DP.Mims_Sub_Cat
    ORDER BY SUM(FD.Cost)) AS RANKedColumn
    FROM DIM_Product DP, FACT_Dispensary FD, DIM_Time DT, DIM_Client DC
    WHERE DP.Product_KEY = FD.Product_Key
    AND FD.Time_KEY = DT.Time_KEY
    AND FD.Client_Key = DC.Client_KEY
    AND DT.[Year] = 2007
    AND DT.[Month] IN (2)
    AND Client_name LIKE '%Medicare%'
    AND DP.Manufacture_Name LIKE '%Cipla%'
    AND DP.Mims_Sub_Cat IN (SELECT Mims_Sub_Cat)
    ) SUbquery
    WHERE RankedColumn <=20
    HTH, Jens K. Suessmeyer.
    http://www.sqlserver2005.de

  • Selecting top 10 rows based on one column.

    Hi,
    I need to display the top 10 records for each distinct value of a column. 

    USE Northwind;
    -- Solution 1
    SELECT S.SupplierID, S.CompanyName, CA.ProductID, CA.UnitPrice
    FROM dbo.Suppliers AS S
      CROSS APPLY
        (SELECT TOP (10) *
         FROM dbo.Products AS P
         WHERE P.SupplierID = S.SupplierID
         ORDER BY UnitPrice DESC, ProductID DESC) AS CA
    ORDER BY S.SupplierID, CA.UnitPrice DESC, CA.ProductID DESC;
    -- Solution 2
    WITH C AS
      SELECT S.SupplierID, S.CompanyName, P.ProductID, P.UnitPrice,
        ROW_NUMBER() OVER(
          PARTITION BY P.SupplierID
          ORDER BY P.UnitPrice DESC, P.ProductID DESC) AS RowNum
      FROM dbo.Suppliers AS S
        JOIN dbo.Products AS P
          ON P.SupplierID = S.SupplierID
    SELECT SupplierID, CompanyName, ProductID, UnitPrice
    FROM C
    WHERE RowNum <= 10
    ORDER BY SupplierID, ProductID DESC, UnitPrice DESC;
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • SELECT without ORDER BY - LIFO or FIFO as result?

    Friends, I have a Loop that it inserts in a table that does not possess indice. When I to apply one SELECT, the result will be always the same? This sequencia is important for me. SELECT without ORDER BY functions as a LIFO (stack - Last In, First Out) or FIFO (list/line - First In, First Out)?
    Example:
    declare
    x number := 1;
    Loop
    exit when (x = 11);
    insert into table1 (field1) values (x);
    x: = x + 1;
    end Loop;
    When I will be to apply SELECT in the table ' table1 ' without ODER BY, which result that always will be returned?
    I) 1, 2, 3, ..., 10?
    or will be able to come in another order?
    II) 10, ..., 3, 2, 1
    thanks

    Oracle does not guarantee the rows order when ORDER BY is not specified.
    From Oracle documentation :
    order_by_clause
    Use the ORDER BY clause to order rows returned by the statement. Without an order_by_clause, no guarantee exists that the same query executed more than once will retrieve rows in the same order.

  • You Cannot select assembly order for deletion error with BAPI_SALESORDER_CAHNGE after EHP6 upgrade

    Hi All,
    We are using Z transaction to update Wbs element data to sales order line item through BAPI_SALESORDER_CHANGE. After EHP6 upgrade while updating Wbs element data to old sales orders(Created before EHP6 upgrade)  we are getting  You cannot select assembly order < order number> for deletion (V1 748) error in BAPI return table, For multiple Sales order run.
    But if  we run the same order individually it is getting processed successfully. W e are passing the same values in individual and multiple case.
    We debugged the BAPI and found one more error related to Authorization, But BAPI return table is giving different error (V1 748)message. Please help us in finding the issue.

    Hi Sujay..
    Please check.
    http://help.sap.com/saphelp_47x200/helpdata/en/b7/58c4c87e0811d2b66a0000e82d8bd1/frameset.htm

  • Query:Dispatch selective process orders from a list available

    Hi all,
    we have a requirement in PP module to dispatch only selective process orders(based on a User criteria) from within a Zprogram.To achieve the same,
    1)we have tried to do a BDC of transaction code CM25.But the line selection of the required order to be dispatched is not captured in recording.
    2)Also,we have tried using the CM40 transaction(mass dispatch) and tried to control the orders dispatch through a user exit.This seems to working fine when CM40 is run independently.but the user exit does not get triggered when CM40 is called (using BDC)from within a Zprogram.
    Can someone please throw some light/suggest any alternative for achieving the same i.e dispatch a selected process order from a list of available orders.

    Hi all,
    we have a requirement in PP module to dispatch only selective process orders(based on a User criteria) from within a Zprogram.To achieve the same,
    1)we have tried to do a BDC of transaction code CM25.But the line selection of the required order to be dispatched is not captured in recording.
    2)Also,we have tried using the CM40 transaction(mass dispatch) and tried to control the orders dispatch through a user exit.This seems to working fine when CM40 is run independently.but the user exit does not get triggered when CM40 is called (using BDC)from within a Zprogram.
    Can someone please throw some light/suggest any alternative for achieving the same i.e dispatch a selected process order from a list of available orders.

Maybe you are looking for

  • Automatic Payment program -line item cleared not displaying in table

    automatic Payment program -line item cleared not displaying in table i have re run the APP program DUSR1 same earlier it has run twice but table dose not show double payment to vendors how to resolve the issue. Can some one please guide me on this.

  • Old pictures can not display after Itunes upgrade

    Earlier today I updated to the newest version of Itunes. I also added some new pictures to my synched directory for pictures (this directory has approx 725 pics that were all on my phone prior to this update of Itunes). When I synched to add the new

  • Music Sync Issues with Windows 7 PC

    I am having issues where iTunes freezes when syncing music to my iPad. iTunes completely freezes, the sync doesn't complete, and the music is not seen as visible to the PC until a reboot. There are other posts in the forum for Mac users that talk abo

  • XML Data Source - RSA7 Queue

    I have a datsource created for an XML incoming data into BW . I have followed all the steps mentioned in the SAP documentation . I am getting the queue displayed in the RSA7 ,but when XI is sending XML data to BW , it is coming and displaying in the

  • Photo Booth Not Opening for iSight

    I just got my Macbook. Photobooth will not open, nor will Preview. I haven't tried a few other programs (Comic Life, etc.), but I'm mainly concerned about Photo Booth and Preview. I wanna see my **** pdf's and take pictures with my iSight :c The came