Order by error in union

When I want to sort an union query by using substr I get the error ora-01785. I have tried to solve the problem but still I can't solve it. pls help...
select count(*), dealer.locid ,locname
from dealer,loc
where dealer.locid=loc.locid
group by dealer.locid,locname
union
select count(*)-1,locid,locname
from loc
where locid not in(select dealer.locid
from dealer,loc
where dealer.locid=loc.locid
group by locid,locname
order by substr(locname,2,5) <<---- ora-01785

Achyot,
I think in the two queries you should select the same set of data.But in your query
select count(*), dealer.locid ,locname --you have selected count(*), dealer.locid ,locname
from dealer,loc
where dealer.locid=loc.locid
group by dealer.locid,locname
union
select count(*)-1,locid,locname --dealer is missing here
from loc
where locid not in(select dealer.locid
from dealer,loc
where dealer.locid=loc.locid
group by locid,locname
order by substr(locname,2,5)
In the 2 nd query select dealer also. I don't think the problem is with substr.Try it.
I saw by mistake dealer,locid.Never mind.
Message was edited by:
Manas

Similar Messages

  • Using order by with the UNION ALL operator

    Hi,
    I have 2 queries and i'm using UNION ALL to join both of them.
    And i want to sort the final result based on a column.
    When i try to do that, its not allowing me to use the ORDER BY clause.
    Any suggestions??
    Example
    select * from xxx where job='Manager'
    order by ename
    union all
    select * from yyy where job='Engineer'
    order by ename
    Thanks in advance
    --Kumar                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    SQL> select * from test_emp where deptno = 10 order by ename
      2  union all
      3  select * from test_emp where deptno = 20 order by ename;
    union all
    ERROR at line 2:
    ORA-00933: SQL command not properly ended
    SQL> select * from test_emp where deptno = 10 --order by ename
      2  union all
      3  select * from test_emp where deptno = 20 order by ename;
    select * from test_emp where deptno = 20 order by ename
    ERROR at line 3:
    ORA-00904: "ENAME": invalid identifier
    SQL> select * from test_emp where deptno = 10 --order by ename
      2  union all
      3  select * from test_emp where deptno = 20 --order by ename;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7698 BLAKE      MANAGER         7839 01-MAY-81       3141          1         10
          7782 CLARK      MANAGER         7839 09-JUN-81       2700                    10
          7839 KING       PRESIDENT            17-NOV-81       5512                    10
          7934 MILLER     CLERK           7782 23-JAN-82       1433                    10
          7369 SMITH      CLERK           7902 10-OCT-06        882        123         20
          7566 JONES      MANAGER         7839 10-OCT-06       3279        123         20
          7788 SCOTT      ANALYST         7566 11-OCT-06       3307        123         20
          7876 ADAMS      CLERK           7788 10-OCT-06       1212        123         20
          7902 FORD       ANALYST         7566 10-OCT-06       3307        123         20
    9 rows selected.
    SQL> select * from
      2  (select * from test_emp where deptno = 10 union all
      3  select * from test_emp where deptno = 20)
      4  order by ename;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7876 ADAMS      CLERK           7788 10-OCT-06       1212        123         20
          7698 BLAKE      MANAGER         7839 01-MAY-81       3141          1         10
          7782 CLARK      MANAGER         7839 09-JUN-81       2700                    10
          7902 FORD       ANALYST         7566 10-OCT-06       3307        123         20
          7566 JONES      MANAGER         7839 10-OCT-06       3279        123         20
          7839 KING       PRESIDENT            17-NOV-81       5512                    10
          7934 MILLER     CLERK           7782 23-JAN-82       1433                    10
          7788 SCOTT      ANALYST         7566 11-OCT-06       3307        123         20
          7369 SMITH      CLERK           7902 10-OCT-06        882        123         20
    9 rows selected.
    SQL>

  • Creating a planned order with error "Material requires configuration"

    Dear All,
    I am facing a problem for creation of a planned order with error "Material requires configuration".
    To follow the note 180317, I change Account Assignment Category to "U" (Unknown).
    However, the system still does display the same error.
    Could you please help provide possible solution for this?
    Regards,
    Phong

    See also the following blog post:
    Configurable planned order for material variants: Exception "53: No BOM explosion due to missing configuration"
    BR
    Caetano

  • PO order number error in Sales order

    Hai Everybody,
    I have a problem of PO order number error in the sales order.
    While creating Sales order, i am entering the PO order number in SO.
    Though the document is complete, i am getting this error message : "ordering errors; tested ORGID: 7147144007" and unable to proceed further (saving order & delivery).
    Please give me some inputs to solve the issue.
    Thanks in advance
    Jaya

    Thanks for your inputs.
    @Ram : i have created the same senaerio in Quality system though manual entries still i am facing the same problem i dont know how they have created in Production system, how to find out please tell me.
    @Raghu.k : i have checked in VOV8 ( check po number is set blank which means no check ), still i am facing the problem.
    Please suggest further to solve the issue.
    Thanks
    Jaya

  • CRM orders with error "Do not enter a business agreement for sold-to party"

    Dear SDN'ler,
    after creating orders in SAP CRM via ISA (CRM 4.0) and uploading them to R/3 all orders are created successfully in R/3 but an error message is sent back to SAP CRM in case of ALL orders.
    Error message is the following:
    "Do not enter a business agreement for sold-to party xyz"
    Message no. CRM_BILLING011
    Diagnosis
    The field "FI-CA active" is not selected for the sold-to party 6000201 in the business master record. Since the business agreement is used in the component FI-CA, excluding the control of processes, it makes sense to enter a business agreement.
    Procedure
    Delete the entered business agreement.
    ==> Could someone please give me some more information about the mentioned "business agreement"? Where do I find field "FI-CA active" (in R/3 or CRM customer master data?)?
    ==> And how can I eliminate this error message for CRM orders in SAP CRM?
    Thanks a lot.
    Best Regards,
    Rainer Gryschka

    Please check the customising setting under following path:
    SPRO --> Customer Relationship Management --> Master Data --> Business Partner -- > Business Agreement --> Define Basic Settings
    Alternatively you may also check following customisation table using SM30 --> CRMC_BUAG_ACTV

  • Service Order Creation Error

    Hi,
    I am creating Service Order from SD Order using Requirement class for the Sales of Services.
    Service Order will be used for Service Execution.
    The Problem is when I used Service Product (DIEN) quantity more than one, system stops to create Service Order & Flash Error message.
    Pls suggest, how I can create more than one service order using more than one DIEN Item Quantity .
    High response will be helpful.
    regards
    Ravi

    Dear,
    could you pls tell me what is the error you are getting
    regards
    satish

  • Order by clause with union

    Hi,
    I wanted to know if this is possible with order by clause and union. some how union messes up the ordering of the left part of the union statement.
    assume the data is as below in table tab1
    c1 c2
    4 1
    4 2
    5 1
    5 2
    7 1
    7 2
    8 3
    9 4
    the expected output must be for all c1 < 7 ordering must be on c1 and for all c1 > 7 ordering must be on c2.
    so the query i tried was
    select c1,c2 from tab1 where c1 <7 order by c1
    union
    select c1,c2 from tab1 where c1 >=7 order by c2
    it is giving the message 'Sql command not properly ended'.
    Suggestions are welcome

    SQL>
    SQL> With t As
      2  (
      3  Select 4 c1, 1 c2 From dual Union All
      4  Select 4 ,2       From dual Union All
      5  Select 5 ,1       From dual Union All
      6  Select 5 ,2       From dual Union All
      7  Select 7 ,1       From dual Union All
      8  Select 7 ,2       From dual Union All
      9  Select 8 ,3       From dual Union All
    10  Select 9 ,4       From dual
    11  ), t1 As (Select c1,c2 From t Where c1 <7 Order By c1)
    12  ,t2 As (select c1,c2 from t where c1 >=7 Order By c2)
    13  Select * From t1 Union All
    14  Select * From t2;
            C1         C2
             4          1
             4          2
             5          1
             5          2
             7          1
             7          2
             8          3
             9          4
    8 rows selected
    SQL> /*-- Union All
      2   select c1,c2 from t where c1 >=7
      3   Order By c1,c2;
      4  */
      5 
    with union clause order by must be placed in the end,,
    select c1 from dual union all
    select c2 from dual
    order by  c1

  • Order Frauded (Error Id: 10000)

    Hello.
    I tried up upgrade a previously purchased app today on my Curve 9300, and received an "Order Frauded (Error Id: 10000)" message. 
    After some searching here and elsewhere on the web, I tried a number of things including:
    Change payment from PayPal to credit card
    Verified all payment information within by BlackBerry ID
    Verified all PayPal card and address information
    Created and linked a brand new PayPal account
    Hard resets (battery pull)
    Removal and reinstallation of App World (3.1.0.60)
    App World cache clear (Alt R S T)
    All without success...  The "Order Frauded (Error Id: 10000)" error remains, both trying to purchase an app upgrade and also when trying to purchase a new app.
    I found lots of references to Error Id 10000, but no specific reference to the (gramatically questionable) Order Frauded message.
    The last time I successfully purchased an app was in Decmeber.
    Any ideas?
    Thanks.
    Curve 9300 5.00.832 bundle 1399 with App World 3.1.0.60.

    Don't even bother dude...I had this problem ever since I purchased a BB...blackberry tech obviously dont give 2 stuffs about the matter.  Tried Visa, mastercard, paypal, prepaid credit cards, debit cards all with out success...if its not an order frauded message its an authorization problem message.  These fools have stolen atleast 10 dollars of me in 1 dollar fund checks and still no avail. >.<
    The blacker the berry the sweeter the juice

  • Purchase Order Interface Error

    Can any body help me out to resolve the issue.
    After inserting in the PO interface tables (PO_HEADERS_INTERFACE , PO_LINES_INTERFACE, PO_DISTRIBUTIONS_INTERFACE ) when I run request ( Import Standard Purchase Orders) following error occured. And no error is inserted in PO_INTERFACE_ERRORS also.
    ORA-01422: exact fetch returns more than requested number of rows in Package po.plsql.PO_PDOI_PVT. Procedure init_sys_parameters.0
    ORA-01422: exact fetch returns more than requested number of rows in Package po.plsql.PO_PDOI_PVT. Procedure init_startup_values.10
    ORA-01422: exact fetch returns more than requested number of rows in Package po.plsql.PO_PDOI_PVT. Procedure start_process.50
    User-Defined Exception in Packaged po.plsql.PO_PDOI_Concurrent. Procedure POXPDOI.30
    Regards,
    Siraj Gul

    Dear Sandeep,
    Thanks alot for the help. After your instruction when I run concurrent request following message show.
    --> To get the log message for PDOI, please use the following id to query against FND_LOG_Messages Table: AUDSID = 8621728
    --> Concurrent request completed successfully.
    But No data found in the table "fnd_log_messages"
    And Neither data deleted from PO_Header_interface table nor inserted in PO_Headers_All and other detail tables.
    Can you please provide me the script for PO_Headers_Interface, Lines and Distribution.
    Regards,
    Siraj Gul

  • Sales Order Costing Error

    Hallo friends,
      I am getting sales order costing error and it does not allow us to delivery through VL01n. Error shows :
    Object was not costed
    Message no. CK060
    Diagnosis
    The system could not find any entries that are relevant to costing.
    System Response
    The system did not cost the object.
    Procedure
    Check whether the following objects should be flagged as relevant to costing:
    Items in the BOM
    Display BOM
    Operations in the routing
    Control key in the routing
    1. Look at the message log.
    2. Check whether a quantity was specified in the confirmation.
    Kindly give me urgent solution.
    Thanks & regards,
      Samrat

    Hi
    You can just mark your thread as answered
    regards

  • CORM --- There is still WIP for order u201Cu2013 error

    Dear SAP Experts
    When doing CORM (close process order), the error message u201CThere is still WIP for order u201Cu2013 WIP in financial accounting is still to be cleared.
    For this process order, the WIP is calculated in period 11 2009,The order was final confirmed and final settlement to COPA was done on feb 2010, So we tried to reverse the settlement , the settlement on feb 2010 is getting reversed ,but the WIP in period is not reversing in KO88
    How to reverse the WIP posted in period 11 2009 ,now the period is closed for year 2009. now the order status was in CNF . Please suggest  a solution for this .
    Thaanks
    Partha

    HI,
    WIP-posting for a given period is reversed when the settlement for this period is reversed.
    As this is in an already closed fiscal year there is no way to do so as this will change accounting figures for closed fiscal years.
    What causes the "WIP is not zero for order..." message? This needs to be solved and I doubt that the reversal of the old WIP settlement will help you on this.
    Best regards, Christian

  • Any report or Table to see the list of orders  with errors  in SAP CRM?

    Hello All,
    Can anyone help me in getting  a table or report  to find the list of orders with errors in SAP CRM?.
    Let me know if you need any additional information.Thanks in advance.
    Cheers
    Sreedhar
    Edited by: sreedharhazari2 on May 26, 2010 11:59 AM

    Hello Chait,
    I got the solution  by this report CRM_ORDER_CHECK_STATUS.
    Anyhow thanks very much for your inputs.
    Cheers
    Sreedhar
    Edited by: sreedharhazari2 on May 30, 2010 8:48 AM

  • Purchase Order/Item error

    Can anyone tell me which fields I should check if I'm receiving the following error on a Standard Purchase Order Import:
    Error: ITEM ID (VALUE =XX) is not a valid purchasable item.
    I have checked that it is enabled, stock enabled, purchasing enabled. Are there other fields I should check as well?

    Hi there,
    I have no idea what you are asking with the limit po?
    Lynton

  • Sales order costing error found in quotation 2 order line items created in

    Sales order costing error found in quotation 2 order line items created in quotation 5000562
    1st line item with third party
    2nd line item with PTO
    Purchase price was entered in the configuration screen
    1st item : 2,000 EUR
    2nd item: 1,200 EUR
    Purchasing info record was created with variant condition for EUR
    Error in sales order costing:-
    System does not take the purchase price in the configuration screen to
    calculate sales order costing. It incorrectly took 1 EUR from variant
    condition in sales order costing for both items.
    By right, it should take purchase price from configuration screen.
    Pls advise
    Thanks

    no replies and my thread was dead.

  • No delivery if order has error in CRM

    Hi All,
    I want to restrict delivery if system has any error in CRM Order.
    Requirement,
    (1) Created orders are successfully replicated in ECC
    (2) After making some changes in existing order changes are not replicated.
    (3) I want to restrict delivery if order has an any error in CRM.
    Regards
    Jay

    Hi Jay,
              For your Requirement to restrict delivery in CRM System
    SAP CRM has preset Functionality for Orders with Error Status in SAP CRM they do not Replicate to ECC System, So if your Order has an Error Status then it shall not Replicate to ECC System.
    For Achieving your Required Details you may Follow the Steps as mentioned below
    (1) Created orders are successfully replicated in ECC
    For Replication of the Order you need to Configure the Middleware Parameters and Subscription and Publication for Particular System Status for the Order to Replicate to ECC System
    (2) After making some changes in existing order changes are not replicated.
    For Replication of the Order after Changes,Check the Status Profile there is a option for "Business Transaction Control" which should be set to To be Distributed which then allows the Order to Flow to the ECC System after changes have been Made.
    (3) I want to restrict delivery if order has an any error in CRM.
    For this Process you shall require to Configure the System as to Distribute the Order at a Particular status which is the Final status in CRM and you shall have to Configure the Processing of Outbound Delivery on the Same status,due to which if Errors are Present in the Order the Order with Errors doesnt flow to ECC and you shall be able to Stop Processing of the Orders with Errors.
    Hope it Answers  your Queries...
    Revert Back for Further Queries..
    Thanks and Regards
    RK.

Maybe you are looking for

  • Portage from PC to Mac with adobe Creative Cloud program

    I will buy a creative cloud program to work on my PC with Microsoft Windows. If I change to a macintosh platform can I transfer my creative cloud on a Mac ?

  • Setting up Network & Internet via Router on Solaris 10 (x86)

    The problem that I have seems to be a very common one. As a regular windows user I have never had any reason to use any other Operating Systems, however, studying oracle on Sun Systems through university has meant that unless I get my own Solaris mac

  • General database structure

    Can you Please explain about the general database structure(Conventional one). Thanks Govind

  • Cannot select timeline at times

    I am using Premiere Pro 5.0.2 and am having trouble selecting the timeline. Sometimes it works perfrctly and other times I click the timeline and it does not get highlighted, and I cannot do anything in it. Other times I can select the timeline but i

  • Network imac os x7 and windows server via firewire

    Hi Everyone I am trying to speed up the connection/file transfer between an iMac (2.8Ghz Intel Core 2 Duo, Mac OS X 10.7.4) and a Windows Home Server machine. I am trying to use Aperture with a very large photo collection (approx. 120,000).  Since th