Query in the Order byclause used with UNION

Tryna qurey below when I get

ORA-01784 - ORDER BY item must include the number of an expression in the SELECT list

Please help me to solve this problem as soon as possible.


SELECT cm_workqueue. WQUEUEID_REF, cm_workqueue. WQUEUEID_CODE, cm_workqueue.mstr_queue_encode, cm_workqueue.desc_text
OF cm_workqueue.
cm_wkqueue_role,
atrt_role
WHERE cm_workqueue. MSTR_QUEUE_ENCODE = 10000000
AND cm_workqueue. WQUEUEID_REF = cm_wkqueue_role. WQUEUEID_REF
AND atrt_role. ROLEID_REF = cm_wkqueue_role.roleid_ref
AND cm_wkqueue_role. REFERRAL_YORN_ENCODE = 10000000
AND cm_workqueue. STATUS_REF = 10000000
AND cm_wkqueue_role. STATUS_REF = 10000000
UNION
SELECT cm_workqueue. WQUEUEID_REF, cm_workqueue. WQUEUEID_CODE, cm_workqueue.mstr_queue_encode, cm_workqueue.desc_text
OF cm_workqueue.
cm_wkqueue_role,
atrt_role
WHERE cm_workqueue.mstr_queue_encode = 10000001
AND cm_workqueue.status_ref = 10000000
AND cm_wkqueue_role.wqurolid_ref = 1
AND THERE ARE)
SELECT 1
OF cm_filterset f.
cm_wkqueue_role cmr
WHERE f.wqueueid_ref = cm_workqueue.wqueueid_ref
AND f.status_ref = 10000000
AND cmr.roleid_ref = atrt_role.roleid_ref
AND cmr.wqueueid_ref = f.mstrquid_ref
AND cmr.referral_yorn_encode = 10000000
AND cmr.status_ref = 10000000)
ORDER OF CASES
WHEN cm_workqueue.wqueueid_ref < 999 THEN 1
Of OTHER cm_workqueue.mstr_queue_encode
END,
BASS (cm_workqueue.desc_text)

No, you must put the case in the selection list

SQL> select ename, empno, deptno, case deptno when 10 then 2 when 20 then 1 else 0 end dno from emp where deptno = 10
  2  union
  3  select ename, empno, deptno, case deptno when 10 then 2 when 20 then 1 else 0 end dno from emp where deptno = 20
  4  order by 4, ename
  5  /

ENAME          EMPNO       DEPTNO     DNO
---------- ---------- ---------- ----------
ADAMS           7876           20       1
FORD           7902           20       1
JONES           7566           20       1
SCOTT           7788           20       1
SMITH           7369           20       1
CLARK           7782           10       2
KING           7839           10       2
MILLER           7934           10       2

8 rows selected.

SQL> 

Tags: Database

Similar Questions

  • I am currently using Adobe Acrobat Pro and cannot use thumbnail images in some of my PDF files. I have not upgraded and have always the possibility to use with certain PDF files, but not all. Help, please!

    I am currently using Adobe Acrobat Pro and cannot use thumbnail images in some of my PDF files. I have not upgraded and have always the possibility to use with certain PDF files, but not all. Help, please!

    Version: Adobe Acrobat 9 Pro

    Windows

    I found the solution:

    In the PDF file, click View > Navigation panel > Pages

    I had to reset panels to view the Pages again.

    Thank you!

    Heather Solis | Operations associate | Crown AFAM Capital, Inc.

    [personal information deleted by Moderator]

  • Error in query of the ordered result query contained CFSCRIPT in CF10

    I came across a very interesting error when you perform a query of a query within a CFSCRIPT tag...

    I get a result in withdrawal of a SQL Server stored procedure.  This is a list of metric names (METRIC_ID) and the metric measures themselves.

    I need to pull the METRIC_ID for this outcome, plans to make a JOIN on another query having display and other attributes of formatting for display in a web page.

    The following code runs without error when the query is not ordered:

    var displayDataQuery = new Query();

    displayDataQuery.setName ("joinedQuery");

    displayDataQuery.setDBType ("query");

    displayDataQuery.setAttributes (qry1 = fullMetricsListQuery);

    displayDataQuery.setAttributes (qry2 = arguments.cubeData);

    displayDataQuery.setSQL ("SELECT METRIC_ID FROM qry2");

    var tempResultSet = displayDataQuery.execute ();

    var cubeMetricIDList = tempResultSet.getResult ();

    When I take the same results of exact query of the same stored procedure, but it is controlled by an ORDER BY clause, this statement;

    var tempResultSet = displayDataQuery.execute ();

    get the following error: "value" cannot be converted to a number.»   It is 2 apostrophes, meaning an empty string between 'value' and 'impossible.'


    Wait, what?  I want to just a list of names metrics, varchars.  Why is there a conversion error...?


    The error in the end pprovided back to ColdFusion10\cfusion\CustomTags\com\adobe\coldfusion\base.cfc, line 445

    OK, this is where it takes an interesting twist...

    Starting at line 444, in base.cfc, line 445 bolded in red:

    "< cfif sqlType NEQ" "and arraylen (sqlParams) gt 0 >."

    < cfloop index = "i" = "2" to = "#ArrayLen (sqlArray) #" >

    < arraylen (sqlParams) of lte cfif (i-1) >

    < cfqueryparam attributeCollection = "#sqlParams [i-1] #" / >

    < / cfif >

    #getPreserveSingleQuotes (sqlArray [i]) #.

    < / cfloop >

    < / cfif >

    So if I understand correctly, when I have a query, unordered, copy the following code in base.cfc bed the SQL code in displayDataQuery.setSQL ("SELECT METRIC_ID FROM qry2"), but is not when the query is controlled by METRIC_ID... ?

    Oh, wait... the CFDUMP when using an ordered set of data says something else...

    query
    RESULTSET
    CACHINGfake
    EXECUTIONTIME4
    SQLSELECT * FROM qry1 ORDER OF METRIC_ID, LOCATION

    I'm a bit confused why the same data in works set ordered, while an ordered set causes this error.

    All useful suggestions or clues would be greatly appreciated!

    Do you mean that the error has occurred without the order by clause?

    Given that the error only occurs with one unsorted data set, I'm a bit confused why you ask this...?

    I've followed your suggestion:

    Run the same code, but use the cfquery instead of cfscript tag. The error persists there?

    My assumption was that your suggestion is to test it against a set of ordered data because that is what caused the original error.

    Unfortunately, the error occurs in the scenarios the tag and script-based.

    There is absolutely no sense why this happens.  The order of a set of data should have no impact on a query of a query on a column defined as varchar.

    If there are null values in the other columns defined as a type of digital, big deal, the code in question does not seek to assess these columns.  Still more interesting thing is why disorderly orderly vs makes a difference.

  • Will buy the Xoom and use with MIFI

    I intend to buy the Xoom and use it only with Mifi (on the road) and my wireless router (at home), if I have to buy with Verizon CDMA, I'll do it, but I don't intend to start a plan with Verizon, I hope that it works for the units that are selling from 02/17/11.

    The XOOM has wifi, so your Mifi will work with him. you wouldn't buy a package given just the XOOM.

  • change the email address used with BC

    Hey guys,.

    I know he is asked prob amillion times even if I try to change the e-mail address associated with my BC portal, I changed the email that I use in my ADOBE account and also makes you want to change the email used to loging to the BC Partner Portal if it's just me.

    [ERROR: your username, password or both are invalid [ERROR: 1]]

    I really want to get this changed as myself and business partner are breaking the company down and I keep all BC stuff and of course wish to change the e-mail address that is used with it.

    Any help would be great!

    See you soon

    Hard.

    Salvation hard,

    Please join our support live chat live and provide the user ID so that they can study this suite using sort this problem.

    - http://helpx.adobe.com/contact.html?product=business-catalyst

    Kind regards

    -Sidney

  • Stats not registered in the stat table use with gather_table_stats

    During the collection of statistics with DBMS_STATS. GATHER_TABLE_STATS and passing stattab parameter partitioned table, his stats are not saved for this partition in the table user stat unless it is executed twice. Here's the statement that I'm running. If I add a new partition and try to collect statistics for it and store it in the user table stats, it is not be stored even if his dictionary stats are updated. If I run the second time, it will update the entries in the user table stat.

    Start
    DBMS_STATS.gather_table_stats ("OWNER",
    tabname = > 'table_name ',.
    partName = > "P20090824"
    estimate_percent = > 2,
    method_opt = > 'for all THE COLUMNS of SIZE AUTO. "
    stattab = > "DICTSTATTAB"
    granularity = > "ALL."
    degree = > 8,
    Cascade = > true
    );
    end;
    /

    I used similar options and it worked all the time. Only difference is I used the granularity-online 'PARTITION Maybe you give him a try.
    Also try the stat of gathering and export to stat table separately.

  • Question about the database to use with ESX and Labmanager

    Hello

    Finally my company is buying a permit for Labmanager and ESX server using Labmanager to our tests.

    We had a question about the database that we use for the actual installation.

    Could we use MY - SQL? Or that we have the olbigation to install a SQL or Oracle DB for the whole system to work?

    We prefer to use MY_SQL because it is open-source and will cost less to use for us.

    Thanks in advance for the answer and please excuse my bad English, I'm french spoke first.

    Lafa91

    Montreal.

    Lab Manager installs SQL Express as part of the installation and use. If you install also Virtual Center as part of your deployment of Lab Manager (do not use an existing VC server), you can use the database SQL Express is included for small installations of ESX, but MY SQL is not an option. You can search the databases supported in the installation guide for what version you deploy.

  • A question about the analytical function used with the GROUP BY clause in SHORT

    Hi all

    I created the following table named myenterprise
    CITY       STOREID    MONTH_NAME TOTAL_SALES            
    ---------- ---------- ---------- ---------------------- 
    paris      id1        January    1000                   
    paris      id1        March      7000                   
    paris      id1        April      2000                   
    paris      id2        November   2000                   
    paris      id3        January    5000                   
    london     id4        Janaury    3000                   
    london     id4        August     6000                   
    london     id5        September  500                    
    london     id5        November   1000
    If I want to find which is the total sales by city? I'll run the following query
    SELECT city, SUM(total_sales) AS TOTAL_SALES_PER_CITY
    FROM myenterprise
    GROUP BY city
    ORDER BY city, TOTAL_SALES_PER_CITY;
    that works very well and produces the expected result, i.e.
    CITY       TOTAL_SALES_PER_CITY   
    ---------- ---------------------- 
    london     10500                  
    paris      17000            
    Now in one of my books SQL (Mastering Oracle SQL) I found another method by using the SUM, but this time as an analytic function. Here's what the method of the book suggests as an alternative to the problem:
    SELECT city, 
           SUM(SUM(total_sales)) OVER (PARTITION BY city) AS TOTAL_SALES_PER_CITY
    FROM myenterprise
    GROUP BY city
    ORDER BY city, TOTAL_SALES_PER_CITY;
    I know that the analytic functions are executed after the GROUP BY clause has been transformed completely and Unlike regular aggregate functions, they return their result for each line belonging to the partitions specified in the partition clause (if there is a defined partition clause).

    Now my problem is that I do not understand what we have to use two functions SUM? If we only use one only, i.e.
    SELECT city, 
           SUM(total_sales) OVER (PARTITION BY city) AS TOTAL_SALES_PER_CITY
    FROM myenterprise
    GROUP BY city
    ORDER BY city, TOTAL_SALES_PER_CITY;
    This generates the following error:
    Error starting at line 2 in command:
    SELECT city, 
           SUM(total_sales) OVER (PARTITION BY city) AS TOTAL_SALES_PER_CITY
    FROM myenterprise
    GROUP BY city
    ORDER BY city, TOTAL_SALES_PER_CITY
    Error at Command Line:2 Column:11
    Error report:
    SQL Error: ORA-00979: not a GROUP BY expression
    00979. 00000 -  "not a GROUP BY expression"
    *Cause:    
    *Action:
    The error is generated for the line 2 column 11 which is, for the expression SUM (total_sales), well it's true that total_sales does not appear in the GROUP BY clause, but this should not be a problem, it has been used in an analytical function, so it is evaluated after the GROUP BY clause.

    So here's my question:

    Why use SUM (SUM (total_sales)) instead of SUM (total_sales)?


    Thanks in advance!
    :)





    In case you are interested, that's my definition of the table:
    DROP TABLE myenterprise;
    CREATE TABLE myenterprise(
    city VARCHAR2(10), 
    storeid VARCHAR2(10),
    month_name VARCHAR2(10),
    total_sales NUMBER);
    
    INSERT INTO myenterprise(city, storeid, month_name, total_sales)
      VALUES ('paris', 'id1', 'January', 1000);
    INSERT INTO myenterprise(city, storeid, month_name, total_sales)
      VALUES ('paris', 'id1', 'March', 7000);
    INSERT INTO myenterprise(city, storeid, month_name, total_sales)
      VALUES ('paris', 'id1', 'April', 2000);
    INSERT INTO myenterprise(city, storeid, month_name, total_sales)
      VALUES ('paris', 'id2', 'November', 2000);
    INSERT INTO myenterprise(city, storeid, month_name, total_sales)
      VALUES ('paris', 'id3', 'January', 5000);
    INSERT INTO myenterprise(city, storeid, month_name, total_sales)
      VALUES ('london', 'id4', 'Janaury', 3000);
    INSERT INTO myenterprise(city, storeid, month_name, total_sales)
      VALUES ('london', 'id4', 'August', 6000);
    INSERT INTO myenterprise(city, storeid, month_name, total_sales)
      VALUES ('london', 'id5', 'September', 500);
    INSERT INTO myenterprise(city, storeid, month_name, total_sales)
      VALUES ('london', 'id5', 'November', 1000);
    Edited by: dariyoosh on April 9, 2009 04:51

    It is clear that thet Analytics is reduntant here...
    You can even use AVG or any analytic function...

    SQL> SELECT city,
      2         avg(SUM(total_sales)) OVER (PARTITION BY city) AS TOTAL_SALES_PER_CITY
      3  FROM myenterprise
      4  GROUP BY city
      5  ORDER BY city, TOTAL_SALES_PER_CITY;
    
    CITY       TOTAL_SALES_PER_CITY
    ---------- --------------------
    london                    10500
    paris                     17000
    
  • My company goes bankrupt. They gave me the computer they use with a XP disc but I have no activation key

    Hello

    So I have this old model that was given to me by my company when the company went under (a place in R & D that loses funding). It seems to be a generic PC cobbled together from pieces of the difference, some being spare parts. It has a sticker of windows vista in the detail but xp pro installed. They gave me an xp pro disk. However when I uses a key Locator to get the license key and try to use it with the disc, it says it is unacceptable so I think they gave me the wrong disc.

    Is there something I can do? May download and install vista? (shudders at the thought)

    Thank you.

    Hello

    I'll try and help you, but be informed that Microsoft has a policy of a license per machine. If the computers were running on the volume license key, then you will not be able to activate Windows. Usually the license will limit the key to a certain number of facilities which must be only the Organization of the licensee.

    You can find that some clarification on licenses in volume on this article. To find detailed information on the single user license agreement, go through the link and check.

    Hope this information is helpful and let us know if you need more assistance. We will be happy to help you.

  • How to use Plugin-Nik Software with Photoshop Creative Cloud?  I have installed the software I used with Photoshop CS6, but now that I installed CC, I don't know how to access.  Thanks for your help.

    How I used Nik Software Plugin Photoshop Creative Cloud?  I installed it on my iMac and use it with SP6, but now that I use the version of the CC of the PS, I don't know how to access the Nik.  I mainly use SilverEffex Pro for black and white conversion.  Thanks for the instructions.

    [Left the forum Cloud/Installer generic for program specific forum... MOD]

    Hello

    Please, go to the folder of the application on your Mac, find the folder of Photoshop CS 6, double-click to open it and copy the folder plugin from here.

    Open the Photoshop CC folder which will be again in the application and paste the folder plugin inside. Replace reboot of the CC of the Photoshop file and it should be there

    Thank you

  • No e-mail the order after problem with processing status.

    I ordered and received a confirmation email that says there is a problem with the processing system. He said as I would receive an email with the status of my order within 24 hours, and no such email arrived after more than a day. I Don t know how to proceed and access the product.

    Hello Daniela,

    I am able to see an active subscription on your e-mail address, please check if the problem is resolved?

    Kind regards

    Akshay

  • Regarding the count (*) while using with the table alias

    Hello
    I question in Count (*). It will work with table alias.

    It works when I use it as below

    'select count (*) po_headers_all po_header_id' - his works perfectly

    but, when I questioned as below his does not.

    "select count (*) from po_headers_all poh poh.po_header_id".

    I like you guys to clarify my request.

    Thanks in advance.

    Kind regards
    Uvaraja

    Uvaraja wrote:
    Hello
    I question in Count (*). It will work with table alias.

    It works when I use it as below

    'select count (*) po_headers_all po_header_id' - his works perfectly

    but, when I questioned as below his does not.

    "select count (*) from po_headers_all poh poh.po_header_id".

    I like you guys to clarify my request.

    Thanks in advance.

    Kind regards
    Uvaraja

    Does it that way if you want to use the alias with the County, you must do the following:

    Select count (test.column) from my_table test;

    Select test.* my_table test;

  • What is the best to use with photoshop cs6; "mac vs windows"?

    I'm looking to possibly buy again and so loop I'd like ideas. I don't want to spend a fortune on a new laptop and well, I don't want to end up wasting any $ on the wrong type of system. Overall, I need the system to be fast and powerful and work perfect w / software. Can you please help me with my question? Thank you

    Ah, the old versus Mac debate PC. It will really come down to your personal preference, but you'll probably want to go on the Photoshop CS6 technical specification and requirements before settling on a final product: http://www.adobe.com/products/photoshop/tech-specs.html

    The FAQ might be useful too: http://www.adobe.com/products/photoshopextended/faq.html

    Good luck with your decision!

  • Questions about the configuration of the cache for use with partitioned off-lot...

    Once more, I give it a try to see if we can make use of the new partitioned (split) off-heap storage and are having problems with the configuration of the cache (including configuration files).

    The problems that I had, it seems that < high > units should be specified for the entire cluster (or perhaps for a node? not sure yet!) while < original-size > & < size > is specified by partition. Is this correct? That's the way it was intended (for me it would have seemed more logical to also specify < high-units > per partition since I guess overflow checking and expulsion is made by partition)? The way I read the documentation, it seems that all three should be per partition if < partitioned > true < / partitioned > is specified.
    If I value < > 1 mb high-units (as i belive I should if it was per partition) I get the impression that I posted in a previous question (a message to info on some missing index data, then the crash of nodes in cluster with some of out of memory error).

    / Magnus
    <?xml version="1.0"?>
    <!DOCTYPE cache-config SYSTEM "cache-config.dtd">
    
    <cache-config>
        <caching-scheme-mapping>
            <cache-mapping>
                <cache-name>ObjCache</cache-name>
                <scheme-name>off-heap-near</scheme-name>
                <init-params>
                    <init-param>
                        <param-name>front-size</param-name>
                        <param-value>200000</param-value>
                    </init-param>
                </init-params>
            </cache-mapping>
        </caching-scheme-mapping>
    
        <caching-schemes>
            <near-scheme>
                <scheme-name>off-heap-near</scheme-name>
                <front-scheme>
                    <local-scheme>
                        <high-units>{front-size}</high-units>
                    </local-scheme>
                </front-scheme>
                <back-scheme>
                    <distributed-scheme>
                        <service-name>PartitionedOffHeap</service-name>
                        <backup-count>1</backup-count>
                        <thread-count>4</thread-count>
                        <partition-count>127</partition-count>
                        <backing-map-scheme>
                                  <partitioned>true</partitioned>
                              <external-scheme>
                                    <nio-memory-manager>
                                       <initial-size>1m</initial-size> <!-- PER PARTITION?! -->
                                       <maximum-size>1m</maximum-size> <!-- PER PARTITION?! -->
                                    </nio-memory-manager>
                                    <unit-calculator>BINARY</unit-calculator>
                                    <high-units>127m</high-units> <!-- PER PARTITION/NODE/CLUSTER?????? -->
                             </external-scheme>
                        </backing-map-scheme>
                        <backup-storage>
                        <!-- PARTITIONED BY DEFAULT?! -->
                            <type>off-heap</type>     
                        <initial-size>1m</initial-size> <!-- PER PARTITION?! -->
                        <maximum-size>1m</maximum-size> <!-- PER PARTITION?! -->
                        </backup-storage>
                        <autostart>true</autostart>
                    </distributed-scheme>
                </back-scheme>
                <autostart>true</autostart>
            </near-scheme>
        </caching-schemes>
    </cache-config>

    Sorry, my description is very confusing. High units is by cache. What I was trying to say, is that cache mapping can train additional units high to affect the memory required by the node. Since multiple caches can map to the same pattern, especially if you use wildcards in the mapping, you must consider the total number of hidden units of high times. It is true or not caches use different services.

    You are also right about high units, applying to the partitioned support cards. You could have easily expulsion are happening as you describe. We must take another look at the configuration because it is too easy to make a mistake.

    As expected, the allocation of card support splitting is lazy to avoid the problem you described. The worst case situation, I was trying to explain can occur if you have caused all buffers to be allocated based on the data before all other nodes could take some of the partitions.

    Kind regards

    David

  • Where the mouse to use with the Y2P?

    I have a model of mouse Microsoft Optical 3902c 693. I can't make it work with my Y2P. I installed the driver of windows 8 on the Microsoft site and it still does not work. Someone knows why? And what mouse would you recommend that works with the Y2P?

    Here are the mouse:

    http://tinkernorthwest.ecrater.com/p/12964992/Microsoft-Optical-USB-mouse-3902c693

    You shouldn't need a driver installed about any mouse to have at least basic features.

    I have no idea why it wouldn't work. Have you tried both USB ports?

    It appears in Device Manager?

    Z.

Maybe you are looking for