With SEPARATE problem

Why this code does not work?
Select 
    Distinct(Substr(to_char(termid),1,2))

From StoredGrades

Where termid >= 1800

Order By termid
[Error code: 1791, SQL State: 42000] ORA-01791: not a SELECTed expression

Hmm...

satyaki>
satyaki>select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE    10.2.0.3.0      Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production

Elapsed: 00:00:01.54
satyaki>
satyaki>
satyaki>select distinct(substr(to_char(empno),1,2)) res
  2  from emp
  3  where sal > 1000
  4  order by empno;
order by empno
         *
ERROR at line 4:
ORA-01791: not a SELECTed expression

Elapsed: 00:00:00.13
satyaki>
satyaki>
satyaki>select distinct(substr(to_char(empno),1,2)) res
  2  from emp
  3  where sal > 1000
  4  order by substr(to_char(empno),1,2);

RE
--
74
75
76
77
78
79

6 rows selected.

Elapsed: 00:00:00.05
satyaki>

Kind regards.

LOULOU.

Tags: Database

Similar Questions

  • Oracle 11g R1 - with SEPARATE problem

    A very simple request: I want to select the contracts, suppliers, products and count how many times product ordered and how many flags have been used in these orders.

    CREATE TABLE T1 AS
    SELECT 'A1' ORD, 1 LOCN, 123 CONT VNDR 111, 'P' FLG, SYSDATE DOUBLE DT
    UNION SELECT 'A2', 1, 123, 111, 'P', DOUBLE SYSDATE
    UNION SELECT 'A3', 1, 123, 101, THE FROM ', DOUBLE SYSDATE
    UNION SELECT 'A4', 1, 233, 137, 'P', DOUBLE SYSDATE
    UNION SELECT 'A5', 1, 233, 137, THE FROM ', DOUBLE SYSDATE
    UNION SELECT 'A6', 1, 354, 321, THE FROM ', DOUBLE SYSDATE
    UNION SELECT 'A7' 1, 776, 656, THE FROM ', DOUBLE SYSDATE

    ;

    CREATE TABLE T2 AS
    SELECT 123 CONT, VNDR 111, 50 DOUBLE PROD
    UNION SELECT 123,111,60 FROM DUAL
    UNION SELECT 123,111,65 FROM DUAL
    UNION SELECT 233,137,60 FROM DUAL
    UNION SELECT 233,137,11 FROM DUAL
    UNION SELECT 354,321,44 FROM DUAL
    UNION SELECT 776,656,14 FROM DUAL
    UNION SELECT 123,191,49 FROM DUAL

    ;

    AS DUP
    (
    SELECT T1. SUITE
    T1. VNDR
    T2. PROD
    COUNT (DISTINCT T1. FLG) FLG_CNT
    COUNT (*) PROD_CNT
    FROM T1
    T2
    WHERE T1. CONT = T2. SUITE
    AND T1. VNDR = T2. VNDR
    GROUP T1. SUITE
    T1. VNDR
    T2. PROD
    HAVING COUNT (*) > 1
    )
    SELECT DISTINCT
    T1. SUITE
    T1. VNDR
    DUP. PROD
    T1. FLG
    T1. DSB
    T1. DT
    DUP. FLG_CNT
    DUP. PROD_CNT
    FROM T1
    DUP
    T1. CONT = DUP. CONT
    AND T1. VNDR = DUP. VNDR
    AND T1. LOCN = 1

    ORDER OF DUKE. PROD_CNT / / DESC
    DUP. FLG_CNT / / DESC
    T1. SUITE
    T1. VNDR
    DUP. PROD
    T1. FLG
    T1. DSB
    ;

    When I ran it I got

    ORA-01791: not a SELECTed expression

    01791 00000 - "not a selected expression.

    * Cause:

    * Action:

    Error on line: column 25: 27

    Now let's remove DISTINCT COUNT

    Œuvres query!

    Now makes it possible to SEPARATE the County drop and SEPARATE from the SELECT

    Query still works!

    Now put all separate and comment 'AND T1. LOCN = 1 "

    Query works again!


    Now put an "ORDER BY" comment

    Application, it works!

    What a mess!

    Why the use of SEPARATE leads to an error?

    This forum is for discussions of installation problems.

    I think you want the forum SQL-PL/SQL – PL/SQL and SQL

  • Oracle 11 GR 1 material - with SEPARATE problem

    A very simple request: I want to select the contracts, suppliers, products and count how many times product ordered and how many flags have been used in these orders.

    CREATE TABLE T1 AS
    SELECT 'A1' ORD, 1 LOCN, 123 CONT VNDR 111, 'P' FLG, SYSDATE DOUBLE DT
    UNION SELECT 'A2', 1, 123, 111, 'P', DOUBLE SYSDATE
    UNION SELECT 'A3', 1, 123, 101, THE FROM ', DOUBLE SYSDATE
    UNION SELECT 'A4', 1, 233, 137, 'P', DOUBLE SYSDATE
    UNION SELECT 'A5', 1, 233, 137, THE FROM ', DOUBLE SYSDATE
    UNION SELECT 'A6', 1, 354, 321, THE FROM ', DOUBLE SYSDATE
    UNION SELECT 'A7' 1, 776, 656, THE FROM ', DOUBLE SYSDATE

    ;

    CREATE TABLE T2 AS
    SELECT 123 CONT, VNDR 111, 50 DOUBLE PROD
    UNION SELECT 123,111,60 FROM DUAL
    UNION SELECT 123,111,65 FROM DUAL
    UNION SELECT 233,137,60 FROM DUAL
    UNION SELECT 233,137,11 FROM DUAL
    UNION SELECT 354,321,44 FROM DUAL
    UNION SELECT 776,656,14 FROM DUAL
    UNION SELECT 123,191,49 FROM DUAL

    ;

    AS DUP
    (
    SELECT T1. SUITE
    T1. VNDR
    T2. PROD
    COUNT (DISTINCT T1. FLG) FLG_CNT
    COUNT (*) PROD_CNT
    FROM T1
    T2
    WHERE T1. CONT = T2. SUITE
    AND T1. VNDR = T2. VNDR
    GROUP T1. SUITE
    T1. VNDR
    T2. PROD
    HAVING COUNT (*) > 1
    )
    SELECT DISTINCT
    T1. SUITE
    T1. VNDR
    DUP. PROD
    T1. FLG
    T1. DSB
    T1. DT
    DUP. FLG_CNT
    DUP. PROD_CNT
    FROM T1
    DUP
    T1. CONT = DUP. CONT
    AND T1. VNDR = DUP. VNDR
    AND T1. LOCN = 1

    ORDER OF DUKE. PROD_CNT / / DESC
    DUP. FLG_CNT / / DESC
    T1. SUITE
    T1. VNDR
    DUP. PROD
    T1. FLG
    T1. DSB
    ;

    When I ran it I got

    ORA-01791: not a SELECTed expression

    01791 00000 - "not a selected expression.

    * Cause:

    * Action:

    Error on line: column 25: 27

    Now let's remove DISTINCT COUNT

    Œuvres query!

    Now makes it possible to SEPARATE the County drop and SEPARATE from the SELECT

    Query still works!

    Now put all separate and comment 'AND T1. LOCN = 1 "

    Query works again!


    Now put an "ORDER BY" comment

    Application, it works!

    What a mess!

    Why the use of SEPARATE leads to an error?

    I'm a contributor to the original poster.  I managed to recreate the issue on our 11.1.0.7 of databases, but not on any other version including 9.2, 10.2, 11.2.0.3, 11.2.0.4 and 12.1.0.2.  I guess it's a 11.1.0.7 bug or a bug introduced by a patch we have above 11.1.0.7.

    -Bobby

    Here is the log:

    SQL >
    SQL > select * from v version $;

    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    CORE Production 11.1.0.7.0
    AMT for HP - UX: 11.1.0.7.0 - Production Version
    NLSRTL Version 11.1.0.7.0 - Production

    SQL >
    SQL > drop table t1;

    Deleted table.

    SQL > drop table t2;

    Deleted table.

    SQL >
    SQL > CREATE TABLE T1 AS
    2. SELECT 'A1' ORD, 1 LOCN, 123 CONT VNDR 111, 'P' FLG, SYSDATE DOUBLE DT
    3 UNION SELECT 'A2', 1, 123, 111, 'P', DOUBLE SYSDATE
    4 UNION SELECT 'A3', 1, 123, 101, THE FROM ', DOUBLE SYSDATE
    5 UNION SELECT 'A4', 1, 233, 137, 'P', DOUBLE SYSDATE
    6 UNION SELECT 'A5', 1, 233, 137, THE FROM ', DOUBLE SYSDATE
    7 UNION SELECT "A6", 354, 1, 321, THE FROM ', DOUBLE SYSDATE
    UNION SELECT 'A7' 8, 776, 1, 656, THE FROM ', DOUBLE SYSDATE
    9;

    Table created.

    SQL >
    SQL > CREATE TABLE T2 AS
    2. SELECT 123 CONT, VNDR 111, 50 DOUBLE PROD
    3 UNION SELECT 123,111,60 FROM DUAL
    4 UNION SELECT 123,111,65 FROM DUAL
    5 UNION SELECT 233,137,60 FROM DUAL
    6 UNION SELECT 233,137,11 FROM DUAL
    7 UNION SELECT 354,321,44 FROM DUAL
    8 UNION SELECT 776,656,14 FROM DUAL
    9 UNION SELECT 123,191,49 FROM DUAL
    10;

    Table created.

    SQL >
    SQL > DUP AS
    () 2
    3. SELECT T1. SUITE
    4            ,T1. VNDR
    5            ,T2. PROD
    6, COUNT (DISTINCT T1. FLG) FLG_CNT
    7, COUNT (*) PROD_CNT
    8 FROM T1
    9, T2
    10. WHERE T1. CONT = T2. SUITE
    11 AND T1. VNDR = T2. VNDR
    12 GROUP T1. SUITE
    13              ,T1. VNDR
    14              ,T2. PROD
    15 HAVING COUNT (*) > 1
    16)
    17 SELECT DISTINCT
    18 T1. SUITE
    19, T1. VNDR
    20, DUP. PROD
    21, T1. FLG
    22, T1. DSB
    23, T1. DT
    24, DUKE. FLG_CNT
    25, DUP. PROD_CNT
    26 OF T1
    27, DUP
    28. WHERE T1. CONT = DUP. SUITE
    29 AND T1. VNDR = DUP. VNDR
    30 AND T1. LOCN = 1
    31 ORDER OF DUP. PROD_CNT / / DESC
    32, DUP. FLG_CNT / / DESC
    33, T1. SUITE
    34, T1. VNDR
    35, DUP. PROD
    36, T1. FLG
    37, T1. DSB
    38;
    COUNT (DISTINCT T1. FLG) FLG_CNT
    *
    ERROR on line 6:
    ORA-01791: not a SELECTed expression

  • Verizon said I can be faced with one problem with my browser and don't charge but ATT, gmail and other

    Tried loading Verizon homepage, but it says I can be faced with a problem with my browser. ATT, gmail between other fine load and Verizon was very well for some time now, what should I do? I'm not tech savvy so please keep it simple for me, thank you.

    Try to clear your browser's cache.

    Firefox button or tools > clear recent history... - details and of course Cache hit only is selected, and then select all and click the clear now button.

  • Presario SR1463CL with drivers problems

    Please be tolerant of beginners.

    I purchased a SR1463CL to add to a DELL Dimension - old but never fails. -the HARD drive was crushed. I replaced the HDD Samsung with Western Digital. I have replace the dial-up modem. All this without problems. I installed Windows XP Pro and SP2 update. My system detects "New hardware" drivers VGA Compatible and multimedia controller. I have had no success finding the right drivers and their installation. My monitor works find, but I have no sound.

    Poster 'sounds, video controllers' Device Manager with the problems. Initial device showed sound and audio by default to the Modem. I removed which and at this point no device is indicated.

    Device Manager shows no driver found for new hardware and online search has failed. Windows Update detects any is available. I checked on the resource one manufacturing line have failed in my downloadsfrom RealTek and Nvidia.Dial - up has had major periods and material has been identified as there's no way for the system. Previous owner had made the back-ups-DVD-but they went "purple haze" and could not be read. That's why I installed XP Pro.

    My modem does not work on and additional time. It will connect and funtion but after a few minutes I'll get "Page not found" displayed.

    So, I use my Dell Dimension for internet troubleshooting. Any help is greatly appreciated.

    Respectfully.

    "Submariners do it deeper."

    Thanks for the information. Due to serious conflicts resulting from auto-updates from microsoft, which I had to reformat the HARD drive and have located since the necessary drivers to the www.sis.com for VGA and www.realtek.com for audio AC 97 readers to be precise. Manually review and choose downloads in the future.

    "Greens, all councils prepare to dive."

    Thanks again for your help. It is greatly appreciated.

    Bamabubblehead went to the abyss.

  • My macbook air running hot and the battery drains quickly can help you with this problem?

    My macbook air running hot and the battery drains fast is a 13 ", at the beginning of 2014.  Processor 1.4 GHz intel core 15Can you help with this problem?

    Apps can affect the performance of Mac, battery, temperature and fan activity - Apple Support

  • just installed new update for itunes. When I go to the page stoe it flashes really hurt. anyone with this problem. is there a solution?

    just installed new update of itune. When I go to store the page, it's really bad flicker.  anyone with this problem. is there a solution?

    Widely not reported, no known resolution until Apple release a new version of iTunes that affects it.

  • two drivers of PXI chassis with Configuration problem

    Hello

    I have two PXI chassis. One is PXI 1033 and works perfectly with the NI PXI-5404, 5105, 6509, 1409, installed 8336. The other is 1036 PXI with the PXI-5404 NI, 8366 installed. When I was trying wreath connect, as master 1033, 1036 as slave, I found several problems.

    1. in the Measurement & Automation Explorer, does not have my good guys in 1033. Instead, there is a sign of the Red Cross in bottom right with 6509, 5105, 5404.

    2. I can't find an another 5404 of the 1036. In fact, I can't find 1036 in MAX.

    Update BIOS. My PXI system is already identified under the name 'NOR PXI - 1033 Embedded MXI Express' and Chassis1 is identified as 'NOR PXI 1033'.

    So I made several tests as below:

    1. unscrew the 5404 1036 slave. MAX can configure 2 1036 chassis. Ok. But when I reconnect 5404 in 1036, same result happened as stated above.

    2 uninstall the driver of 5404, so the 5404 in 1033 does not either now. And then reboot again, same result happens again. Cannot detect the 1033 chassis. Other vouchers in 1036 don't work either.

    Please, any suggestion is highly appreciated.

    Sincerely,

    Bin

    Hi Ben,

    This happens sometimes with MXI-Express:

    Error code 12 with MXI-Express

    http://forums.NI.com/T5/PXI/two-PXI-chassis-connection-with-configuration-problem/m-p/1475876#M9033

    In general, you can read this error 12 means on Device Manager:

    Explanation of error codes generated by Device Manager in Windows XP Professional

    http://support.Microsoft.com/kb/310123

    If it was a problem of bandwidth, PCI or PXI side, you could pull a few cards to see if that alleviates the problem, or that the link from Microsoft over the States, you can disable the driver for other cards.

  • When you install the 2007 Microsoft Office Suite Service Pack 2 (SP2), I still received the error code 646... I tried to download the RegCure as advised, but the problem still exists... Please help me with this problem... Thank you

    Ideas:

    • When you install the 2007 Microsoft Office Suite Service Pack 2 (SP2), I still received the error code 646... I tried to download the RegCure as advised, but the problem still exists... Please help me with this problem... Thank you

    I tried to download the RegCure as advised, but the problem still exists...

    Who advised you to 'download... '. RegCure? Doing so could only worse issues! If you ever think that your registry database must be cleaned, repaired, boosted or optimized (it isn't), read http://aumha.net/viewtopic.php?t=28099 and draw your own conclusions.

    See http://social.answers.microsoft.com/Forums/en-US/vistawu/thread/6e716883-7af4-4a9f-8665-2f4dd57eee8d ~ Robear Dyer (PA Bear) ~ MS MVP (that is to say, mail, security, Windows & Update Services) since 2002 ~ WARNING: MS MVPs represent or work for Microsoft

  • I have a frozen screen of Active recovery of white desk with a mouse. I think that the computer is frozen upward with a problem of recovery? Right?

    I have a frozen screen of Active recovery of white desk with a mouse.  I think that the computer is frozen upward with a problem of recovery? Right?

    How can I fix?

    Hello
    • What were the changes made before the problem occurred?

    You can try to restart the computer and check if it helps.

    If above does not help, you can read the following steps to disable the active desktop on the computer and check:

    a. to disable Active Desktop.
    b. right click on an area empty office, point to Active Desktop, and then click view as Web Page to clear the check box.
  • I need a list send me Windows based utility of magnification for XP, am a MSN user with vision problems and cannot zoom in easily on what I have.

    I need a list, sent me to my XP Windows-based magnification utilities, am a user of MSN base with vision problems and cannot zoom in with what I have, and the work of the "Magnifier" somewhat well but could use something better.

    Any ideas?

    Hello

    Please refer to the links and check if it helps.

    How to set accessibility features for people who are blind or who have low vision in Windows XP

    http://support.Microsoft.com/kb/308978

     

    Windows XP accessibility tutorials

    http://www.Microsoft.com/enable/training/windowsxp/default.aspx

    Overview of the magnifying glass

    http://www.Microsoft.com/resources/documentation/Windows/XP/all/proddocs/en-us/magnify_about.mspx?mfr=true

    I hope the information is useful!

  • I am also having the same problem with the same updates. I have Windows XP SP3 and it's updates with the problem.

    I am also having the same problem with the same updates. I have Windows XP SP3 and it's updates with the problem.

    Security Update for Microsoft .NET Framework 2.0 SP2 on Windows Server 2003 and Windows XP x 86 (KB2572073)
    A security update for .NET Framework 2.0 SP2 and 3.5 SP1 on Windows Server 2003 and Windows XP x 86 (KB2518864)
    Security Update for Microsoft .NET Framework 2.0 SP2 on Windows Server 2003 and Windows XP x 86 (KB2633880)

    They all install properly but switches back to windows update to install. It's some kind of loop.

    Hi billy73,

    In addition, if you still have questions, please take a look at the thread similar here with a solution as possible.

    I hope this helps!

  • New SSD speed with u410 problem

    Hi, I would ask about my problem. Yesterday I had my old ssd Dams in my ideapad u 410 with one

    A - Data 32 GB SP300 first Pro

    Data sheet:

    Read: 280 MB/s.
    Writing: 260 MB/s.
    IOPS / s: read 12 500/writing 46 000 (random maximum write 4 K)

    and runing on Windows 8 profesional x 64. When I run Crystal diskmark my results are lower as the old 24GB ssd card, I am now around 47 MB/sec write, the old ssd played 69 MB/sec.

    Can someone help me with this problem?

    Thank you.

    renamed topic

    Some ssd compress the data and give you a speed of data compress in their specifications, your old ssd drive might not make it.

    Crystal diskmark performance and go towards the senior, the file / test data / select all 0 x 00 (population 0) and rerun the test.

    John.

  • Since I use 'Microsoft Bluetooth Mobile Keyboard 6000' with separate numeric keypad, I can't use the ASCI codes.

    Original title: ASCI codes with separate numeric keypad.

    Hi all

    Since I use 'Microsoft Bluetooth Mobile Keyboard 6000' with separate numeric keypad I can't use codes ASCI. Y at - it software or setting, which allows to manage this?

    Thank you very much.

    Hello Stephen,

    I have another, better solution now (hint of a colleague): I changed the code of the NumLock key to the ALT key code (I need not the normal function of the NumLock key). Now, I can type ASCI codes with the keys on the keypad num only and it works :-).

    You can change codes for keys in the registry. Unfortunately, I have only a German description for this in Windows XP (http://www.computerhilfen.de/hilfen-5-80753-0.html). But I am sure, there will be English descriptions in the web as well.

    Best regards

  • WHEN I OPEN INTERNET EXPLORER THE E-mail INSERT attachment only WILL NOT WORK - BUT OPEN WHEN IT WITH ADD - no one seems to help me with this problem?

    WHEN I OPEN INTERNET EXPLORE THE INSERT ATTACHMENT WILL WORK - BUT WHEN HE OPENS WITH ADD - NO ONE SEEMS TO HELP ME WITH THE PROBLEM OF TIS!

    That means '' BUT WHEN OPEN IT WITH ADD? '' With no Add-ons? Have you tried allowing add-ons one at a time until you find out that one is the cause of the problem?

    "NO ONE SEEMS TO HELP ME WITH THE PROBLEM OF TIS!

    Have you thought to ask in the forum Internet Explorer?

    Internet Explorer forums
    http://answers.Microsoft.com/en-us/IE

Maybe you are looking for