Unique record to display, with ORDER BY

Table order
Order_Number, Cust_Name
222, XYZ
223, XYZ
224, ABC
Table Product
Order_Number, p_name
222, p1
222, p2
222, p3
223, p1
223, p4
here i need to display only 2 records (1 record for one order number) but with ORDER BY as below
SELECT Order_Number, Cust_Name
FROM order o
INNER JOIN Product p ON (o.Order_Number = p.Order_Number)
WHERE o.Cust_Name = 'XYZ'
ORDER BY p_name;
1) If i put DISTINCT, below error
SQL Error: ORA-01791: not a SELECTed expression
01791. 00000 - "not a SELECTed expression"
2) If i put GROUP BY, below error
SQL Error: ORA-00979: not a GROUP BY expression
00979. 00000 - "not a GROUP BY expression"
please help me to form the query

Try this
select o.order_number, o.cust_name
  from (
select o.*,p.*, row_number() over(partition by o.order_number order by p.p_name)
  from order o
  join product p
    on o.order_number = p.order_number
where o.cust_name = 'XYZ'
where rno = 1

Similar Messages

  • Material document display with ordering address

    Hello all,
    When we create a purchase order and do not order from the "main" (VN) vendor but from an ordering address (OA), and post the goods receipt (101) against this PO, then the material document records only the VN number and not the ordered from number. 
    Is there a list/display that shows all material documents for an order from address versus the vendor address?
    Thanks,
    Annabelle R.

    Thank you very much.
    In addition, as per SAP Library:
    Purchasing > Master Records from the Purchasing View > Vendor Master Data > Partner Roles in Purchasing:
    "In the Logistics Information System (LIS) and in the Business Information Warehouse (SAP BW), you can only run analyses for vendors. You cannot run analyses for any of the other partner roles supplied in the standard system."

  • Alternative to find unique records with 60 character in selection string.

    Hi,
    We have to find out the values from the Infoobject. When we try to display data from an master object, the maximum length of selection it accepts 45 characters only but we need to input data around 60 characters in selection.
    Thing we tried:
    1. Selecting complete data without any condition but it did not work due to large volume of data.
    2. We tried to extract data from RSA3 but it did not work due to large volume of data.
    Please suggest me alternative to find unique records with 60 character in selection string.
    Regards,
    Himanshu Panchal.

    This sounds a bit strange. Are you perhaps mistakenly storing text data incorrectly as the primary key of the master data? I can't think of any actual data that is that length to ensure usinqueness - even GUIDs are maximum 32 characters - but GUIDs don't count as actual "readable" data although you do need to be able to select it from time to time. Perhaps you have a super secure password hash or something like it ?
    Also are you expecting to have a unique single record returned by your selection? To do this would in general REQUIRE that ALL the data is read because master data is not stored in the DB sorted by the data itself, but stored instead sorted by the it's SID.
    When you say you are selecting data from master data, which master data tables are you using? I have been able to select data from very large MD table (15 million unique records) using SE16 with no problems. Just enter the table name, and before you execute just count the number of records - it helps to know what you want to end up with.
    Have you tried using wild cards (the *) to preselect a smaller number of records : * a bit of your 60 character string *
    If you are trying to select from a non-key field you will encounter performance issues, but you can still use the wildcards, and get a result.
    Don't use RSA3 it was designed to make selections and group them into datapackets. It's not the same as selecting directly on the table in SE11 or SE16

  • Vendor line item display with internal order

    In Vendor line item display is it possibe to see details of the line item of offsetting account .
    For example a expense account is debited & vendor account is credited .At the time expense account debit a internal order has been assigned in line item.
    User wants to see the vendor line item display ( T code FBL1N) with details of internal order appearing in open  line items display  etc .
    Is this possible .I created a layout with order as a field but order does not show any values in the line display of vendor.
    Please revert back if this can be possibe.
    Thanks
    Manoj

    with a combination of notes
    112312 - Line item - Display of offsetting ac information
    373268 - Line item - new display field
    569939 - Line item - Open FI - Absolute amounts
    1034354 - FAGLL03 - Display of offsetting account information
    you should be able to get it there.

  • How to create a record for table PLAF with order type 'NB'.

    How to create a record for table PLAF with order type 'NB'(standard purchase order).
    who can tell me the T-code or some usefull information?
    Thanks.

    Hi
    This will be updated automatically when generate planned orders thru MRP. (MD02)
    regards
    Srinivas

  • How many records can be displayed with fm REUSE_ALV_LIST_DISPLAY?

    Hi guys!!!
    Now here's is my problem. I've been trying to display in a program wih fm REUSE_ALV_LIST_DISPLAY, aproximately 450,000 records. But the fact is that after 10 or 15 minutes the system stops the process.
    This case is not the same when I display with the same function a very low number of lines.
    What can I do?
    Maybe one possibility is using the method for ALV List (ALV List Objects)
    h2Please ur answers now!
    Thanks in advance!!!
    Raul Romero

    Hi,
    If you are not expecting to do any additional functionality that the ALV has, like, summing, sorting, filter...etc,
    better display the result in a normal LIST.
    or try to filter your results and in the selection screen, give an option to enter the number records you want to display in the report.
    Regards,
    Subramanian

  • Show OrderType along with name in Display purchase order

    Hi All,
    When we display purchase order via transaction ME23N, first field on the top left hand corner shows description  "Purchase order", "Production order" etc..... Here I would like to see order type (ZB,ZR,ZV etc) along with description.
    There is some way to do that settings. Could someone please let me know step by step process how to set that??
    Thanks.............

    Hi
    In me21n screen in the tool bar the icon called customised local layout.
    In this select options
    In this select Expert
    In this control tab
    Check the check box for show keys in all drop down lists and press ok...
    It will come
    Regards,
    Raman

  • Creditreport that displays Sales Orders with Material Availability Date as

    Hi
    I need input if the following requirement can be met in FSCM credit mgmnt.
    Currently In FDK43 there is a total sales figure that represents the Sales that are consuming the Credit Limit assigned to the customer, unfortunately there is no drill down on this number to see which sales orders are responsible for the consumption of credit
    Do we have any sales report that displays Sales Orders with Material Availability Date as an output in conjunction with Credit limit .

    Not in standard provided. Custom program is required.
    Regards
    Hein

  • T.Code to display Transfer Order with respect to Deliver

    Hi all,
    Can anybody let me know,what is the transaction code to display Transfer Order Created with respect to delivery.
    Thanks in Advance.

    Hi Joginder,
    Thanks for early early.
    Do you know the steps to create TO with respect to delivery.?(by any chance)
    I a technical consultant. I dont have any idea on this.
    I have searched in SDN/Google but couldnt find steps to create TO with delivery.
    Thanks

  • A query to display sales orders with corresponding outbound deliveries

    Hi Experts,
    Don't know if this is the right place to post the question but i would like to know if a query, in SAP, can display sales orders with their corresponding outbound deliveries, i tried using table LIKP and VBAK, VBKD didn't help. the whole idea is to enter any specified sales order number and the query will return any outbound deliveries belong to the sales order.
    Thanks in advance!

    run the se16 transaction - table VBFA.
    This table gives the Sales document flow.
    Give the sales order nos. and in the subsequent document category select delivery.
    You will get all deliveries.
    Thanks
    Ajay

  • Unique data record means you can't  update a record from ECC with same key.

    Unique data record means you can't  update a record from ECC with same key fileds right?
    Details: For example i have two requests Req1 and Req2 in DSO with unique data record setting checked. on day one Req1 has a filed quantity with value 10 in Active data table. On day two Req1 can not be overwitten from ECC with Req2 with the same key fields but different value 20 in the filed quantity because of the Unique data record settings. finally the delta load fails from ECC going to DSO because of this setting. is it right?
    I think we can only use unique record setting going from DSO to cube right?
    Please give me a simple scenario in which we can use this setting.
    I already search the threads and will assign points only to valuable information.
    Thanks in advance.
    York

    Hi Les,
    Unique Data Records:
    With the Unique Data Records indicator, you determine whether only unique data records are to be updated to the ODS object. This means that you cannot load a data record into the ODS object the key combination for which already exists in the system – otherwise a termination occurs. Only use this setting when you are sure that only unique data records are to be loaded into the ODS object (for example, single documents). A typical application of this is in the loading of mass data. It improves the load performance.
    Hope it Helps
    Srini

  • Query Unique Records WITH ROWID

    Hi All,
    I have 2 columns which returns records like this Say Column A and Column B.
    A B
    1 1
    1 1
    2 2
    2 2
    3, 3
    I need only distinct records from these columns. So i executed DISTINCT Clause in my query and it returned unique records. Issue is I need to execute a query like this i.e compulsorily use ROWID in my select list.
    i.e SELECT DISTINCT ROWID A, B from TEST;
    But this query we will give duplicated records only when we give rowid, how to achieve a output like this using rowid in the column select list of my query.
    A B
    1 1
    2 2
    3, 3
    Please Help.
    Thanks in advance.

    If you want just one rowid for each (a, b) couple:
    SQL> select a, b, min(rowid)
      2  from y
      3  group by a, b;
             A          B MIN(ROWID)
             1          1 AAAfoUAAEAAA7T0AAA
             2          2 AAAfoUAAEAAA7T0AAC
             3          3 AAAfoUAAEAAA7T0AAEIf you want all rowid's for each couple:
    SQL>select a, b, rtrim(extract(xmlagg(xmlelement("a",rowid||',')),'//text()'),',') rowids
      2  from y
      3* group by a, b
             A          B ROWIDS
             1          1 AAAfoUAAEAAA7T0AAA,AAAfoUAAEAAA7T0AAB
             2          2 AAAfoUAAEAAA7T0AAC,AAAfoUAAEAAA7T0AAD
             3          3 AAAfoUAAEAAA7T0AAEThanks Buga for posting sample data ;)
    Max
    [My Italian Oracle blog| http://oracleitalia.wordpress.com/2010/02/07/aggiornare-una-tabella-con-listruzione-merge/]

  • O2 order confirmation with Order no & collection reference but no record of mobile on my o2

    Please can someone help?I set up a pay monthly phone online 2 days ago and recieved an o2 order confirmation along with Order No and collection reference in the store I chose to pick up in but I've heard no more. I spoke to the online team and they told me that my order is still with the credit check team. So why have I got an order confirmation? Also I cannot see this order in my O2. So confuse

    If it's with the credit check team still it means you have not yet been accepted so the order won't show and no confirmation until they do approve.

  • Query with order by clause

    Hi,
    I found a query with order by clause in procedure which is taking long time.
    Stats are upto date.
    Total Rows :650000.
    It is ordered by primary key column.
    select * from table_name order by col1;
    col1 is a primary key.No of cpu's used is 4.
    can anyone suggest me a better solution to improve the performance of a query.
    Is it better to use parallel hint for above scenario.
    Any help really apprecaited.
    Thanks in advance.

    Hi,
    Thanks for ur immediate reply.
    It doesn't have where clause.
    below is the plan
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 619071987
    | Id  | Operation                   | Name                 | Rows  | Bytes | Cos
    |   0 | SELECT STATEMENT            |                      |   671K|   255M| 125
    |   1 |  TABLE ACCESS BY INDEX ROWID| FULL_ITEM_FACILITIES |   671K|   255M| 125
    |   2 |   INDEX FULL SCAN           | FIF_PK               |   671K|       |
    9 rows selected
    Executed in 0.094 secondsThanks in advance
    Edited by: unique on Jun 22, 2009 8:26 AM

  • Query with order by & View/procedure

    1)I have a query its getting joined with few tables and the base table contains 12 billion rows . my issue is when I execute the query with necessary parameter am getting the result in few seconds . but when I add an order by for any column am not getting the result even after 15 minuts.
    The sort column is an indexed column and I have even tried with the primary column of the base table but no change .. is there any way to make it faster with order by ??
    2)I have got a view which also getting joined with few high volume tables . when I call the view with required parameter am not getting the result even after 15 minutes.. but when I took out the query of the view and hardcode the value am getting the result in 3 seconds . so I just made it to a procedure that returns a cursor . now its working fine .. could you please explain me the reason for this ….??
    Please help …

    select * from
    (select Rownum RowNO,Qr.* from
    (select T1.c1,T2.C2,T3.c3 from TI,T2,T3
    where < all required joins>
    order by Ti.c)Qr
    where RowNum <20 )
    where RowNO >10 ;As said before:
    Your view very likely prevented predicate pushing and by manually adding the predicate inside the query, you changed the semantics of the query.
    Your view contains a rownum column. This prevents predicate pushing because the semantics of the query changes. An example to clarify:
    SQL> explain plan
      2  for
      3  select *
      4    from ( select empno
      5                , ename
      6                , sal
      7             from emp
      8         )
      9   where empno = 7839
    10  /
    Uitleg is gegeven.
    SQL> select * from table(dbms_xplan.display)
      2  /
    PLAN_TABLE_OUTPUT
    Plan hash value: 4024650034
    | Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |        |     1 |    14 |     1   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    14 |     1   (0)| 00:00:01 |
    |*  2 |   INDEX UNIQUE SCAN         | EMP_PK |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("EMPNO"=7839)
    14 rijen zijn geselecteerd.
    SQL> exec dbms_lock.sleep(1)
    PL/SQL-procedure is geslaagd.
    SQL> explain plan
      2  for
      3  select *
      4    from ( select empno
      5                , ename
      6                , sal
      7             from emp
      8            where empno = 7839
      9         )
    10  /
    Uitleg is gegeven.
    SQL> select * from table(dbms_xplan.display)
      2  /
    PLAN_TABLE_OUTPUT
    Plan hash value: 4024650034
    | Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |        |     1 |    14 |     1   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    14 |     1   (0)| 00:00:01 |
    |*  2 |   INDEX UNIQUE SCAN         | EMP_PK |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("EMPNO"=7839)
    14 rijen zijn geselecteerd.The previous two queries show that in this case the predicate "empno = 7839" can be pushed inside the view. Both queries are semantically the same.
    However, when you add a rownum to your view definition, like you did, the predicates cannot be pushed inside the view:
    SQL> exec dbms_lock.sleep(1)
    PL/SQL-procedure is geslaagd.
    SQL> explain plan
      2  for
      3  select *
      4    from ( select empno
      5                , ename
      6                , sal
      7                , rownum rowno
      8             from emp
      9         )
    10   where empno = 7839
    11  /
    Uitleg is gegeven.
    SQL> select * from table(dbms_xplan.display)
      2  /
    PLAN_TABLE_OUTPUT
    Plan hash value: 2077119879
    | Id  | Operation           | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |      |    14 |   644 |     3   (0)| 00:00:01 |
    |*  1 |  VIEW               |      |    14 |   644 |     3   (0)| 00:00:01 |
    |   2 |   COUNT             |      |       |       |            |          |
    |   3 |    TABLE ACCESS FULL| EMP  |    14 |   196 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("EMPNO"=7839)
    15 rijen zijn geselecteerd.
    SQL> exec dbms_lock.sleep(1)
    PL/SQL-procedure is geslaagd.
    SQL> explain plan
      2  for
      3  select *
      4    from ( select empno
      5                , ename
      6                , sal
      7                , rownum rowno
      8             from emp
      9            where empno = 7839
    10         )
    11  /
    Uitleg is gegeven.
    SQL> select * from table(dbms_xplan.display)
      2  /
    PLAN_TABLE_OUTPUT
    Plan hash value: 1054641936
    | Id  | Operation                     | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT              |        |     1 |    46 |     1   (0)| 00:00:01 |
    |   1 |  VIEW                         |        |     1 |    46 |     1   (0)| 00:00:01 |
    |   2 |   COUNT                       |        |       |       |            |          |
    |   3 |    TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    14 |     1   (0)| 00:00:01 |
    |*  4 |     INDEX UNIQUE SCAN         | EMP_PK |     1 |       |     0   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - access("EMPNO"=7839)
    16 rijen zijn geselecteerd.Now the two queries are not the same anymore. If you wonder why, please look carefully at the query results of both:
    SQL> select *
      2    from ( select empno
      3                , ename
      4                , sal
      5                , rownum rowno
      6             from emp
      7         )
      8   where empno = 7839
      9  /
         EMPNO ENAME             SAL      ROWNO
          7839 KING             5000          9
    1 rij is geselecteerd.
    SQL> select *
      2    from ( select empno
      3                , ename
      4                , sal
      5                , rownum rowno
      6             from emp
      7            where empno = 7839
      8         )
      9  /
         EMPNO ENAME             SAL      ROWNO
          7839 KING             5000          1
    1 rij is geselecteerd.Regards,
    Rob.

Maybe you are looking for

  • Difference between core switch types WS-C3750X-12S-S and N3K-C3524P-10G?

    Hello All, I am new to this domain and yet have to look after the setup of our datacenter for a new branch. Could any one of you provide difference between core switch types WS-C3750X-12S-S and N3K-C3524P-10G! Thanks in advance!!

  • Using of Integration Scenario in a Abap Proxy to JDBC receiver synchronous

    Hi , Can any one help me out  how to go about for creating Integraion scenario in ESR as i'm new to the use of Integration scenario.. its an Abap proxy to Jdbc synchronous scenario... kindly help in this regards.

  • Problems importing songs

    Hello; I am having problems importing songs into Itunes. I have itunes version 11.0.1.12, but this the first time I have this problem, At first it woould only import certain songs (not all of them), later on I cannot import any songs into itunes, I a

  • Profile Management in XIr2

    Post Author: juanmontero CA Forum: Administration Hi all, I would like to ask you for some help about profile management. Actually i know the main process in order to setup profiles to filter information for each user, but here comes my problem, ther

  • The operation couldn't be completed. (NSURLErrorDomain error -3001.)(102)

    This is what I have been getting for the last few days, there are three updates but when I click on "update" it just returns this error, this is happening on my iMac and macair. Is anyone else having the same problem or have a fix ? Thanks in advance