Rownum and group by syntax error

Hi,
I have a query, which use Oracle rownum.
if I put the group by clause to inner select clause, it does not work.
select PS1.PO_ID, PS1.PO_DATE, PS1.POD_PO_ID, sum(PO_ID)
from ( select rownum r_ , A.PO_ID, A.PO_DATE, B.POD_PO_ID
from OPS$RS3.DTINV_PO_DETAIL B, OPS$RS3.DTINV_PO A
where (A.PO_ID <= '450')
group by A.PO_ID, A.PO_DATE,B.POD_PO_ID
) PS1
where r_ > 0 AND r_ <= 10
but if I put the group by clause outside, it work. but this is not what I want.
select PS1.PO_ID, PS1.PO_DATE, PS1.POD_PO_ID, sum(PO_ID)
from ( select rownum r_ , A.PO_ID, A.PO_DATE, B.POD_PO_ID
from OPS$RS3.DTINV_PO_DETAIL B, OPS$RS3.DTINV_PO A
where (A.PO_ID <= '450')
) PS1
where r_ > 0 AND r_ <= 10
group by A.PO_ID, A.PO_DATE,B.POD_PO_ID
Can anybody explain why?
Thanks!
xiong

select PS1.PO_ID
      ,PS1.PO_DATE
      ,PS1.POD_PO_ID
      ,sum(PO_ID)
from  (select rownum r_
             ,A.PO_ID
             ,A.PO_DATE
             ,B.POD_PO_ID
       from   OPS$RS3.DTINV_PO_DETAIL B
             ,OPS$RS3.DTINV_PO A
       where (A.PO_ID <= '450')
       group  by A.PO_ID
                ,A.PO_DATE
                ,B.POD_PO_ID
      ) PS1
where r_ > 0 AND r_ <= 10I don't get what you're trying to do here.
First of all, you have no join condition between the A and B tables of your inline view. That's a cartesian product, probably not what you want.
Also, why do you have '450' in quote marks? Is a.po_id a varchar2 column?
You can't do a GROUP BY like this with rownum in your select list. It doesn't make any sense.
Why do you want row numbers between 1 and 10? Those are just 10 arbitrary rows not based on anything. Or is that what you want?

Similar Messages

  • Urgent ---group by syntax error

    This is my syntax as below.But it doesn't work.Does anyone can tell me what's problem ? or it have another way to solve this quuestion? thanks .
    sql syntax:
    select a.txdate,a.costype,sum(cosamt) * (1+a.cosrate) as costamount
    from sales_cost a
    where a.txdate between '2003-01-01' and '2003-02-01'
    group by a.txdate,a.costype;

    Although more specifics might have helped, I am assuming based on the title of the post: "urgent ---group by syntax error" and my test of the original code that I have identified the error. See the example below for how the original code produces a group by error and how the solution I provided executes without error.
    SQL> -- test data:
    SQL> SELECT * FROM sales_cost
      2  /
    TXDATE      COSTYPE    COSAMT   COSRATE                                                            
    03-JAN-03         1         3        .5                                                            
    03-JAN-03         1         4       .25                                                            
    03-JAN-03         2         4       .75                                                            
    04-JAN-03         3         3        .5                                                            
    04-JAN-03         4         4       .25                                                            
    04-JAN-03         4         4       .75                                                            
    6 rows selected.
    SQL> --
    SQL> --
    SQL> -- wrong:
    SQL> SELECT   a.txdate, a.costype,
      2             SUM (a.cosamt) * (1 + a.cosrate) AS costamount
      3  FROM     sales_cost a
      4  WHERE    a.txdate BETWEEN '2003-01-01' AND '2003-02-01'
      5  GROUP BY a.txdate,a.costype
      6  /
             SUM (a.cosamt) * (1 + a.cosrate) AS costamount
    ERROR at line 2:
    ORA-00979: not a GROUP BY expression
    SQL> --
    SQL> --
    SQL> -- correct:
    SQL> SELECT   a.txdate, a.costype,
      2             SUM (a.cosamt * (1 + a.cosrate)) AS costamount
      3  FROM     sales_cost a
      4  WHERE    a.txdate BETWEEN TO_DATE ('2003-01-01', 'YYYY-MM-DD')
      5                   AND     TO_DATE ('2003-02-01', 'YYYY-MM-DD')
      6  GROUP BY a.txdate,a.costype
      7  /
    TXDATE      COSTYPE COSTAMOUNT                                                                     
    03-JAN-03         1        9.5                                                                     
    03-JAN-03         2          7                                                                     
    04-JAN-03         3        4.5                                                                     
    04-JAN-03         4         12                                                       

  • Dreamweaver CS6 and Coldfusion 9 - Syntax Errors & Code Coloring

    I recently purchased Dreamweaver CS6. 
    Also, I'm running Coldfusion 9 on Windows 7, but that's probably irrelevant.
    The issue is that Dreamweaver keeps on marking my files with syntax errors, and the code coloring gets all messed up.
    For instance, such function would indicate an error due to the #var#:
    <cfoutput><script>functionXYZ(#var#);<script><cfoutput>
    But this would work just fine:
    <script>functionXYZ(<cfoutput>#var#<cfoutput>);<script>
    The issue is that I have entire pages wrapped in cfoutput, redoing everything would take months.
    Or this would break the code coloring for the entire select as such:
    <select <cfif test eq 'test'>class="test"</cfif> name="selectbox">
    While this breaks the code coloring for the closing cfif as such:
    <select class="<cfif test eq 'test'>test</cfif>" name="selectbox">
    I'm getting syntax errors on thousands of my files, I understand that I could rewrite the code slightly to remove some of the error indications, but these are not actual errors so I feel that there is no point of me spending months updating the code.
    Is there a patch that I can apply so that this would work without any of these issues?
    Can someone please help?

    Have you posted this question in the Cold Fusion Forums?
    http://forums.adobe.com/community/coldfusion
    I don't use CF myself and the few CF coders I know have long since moved to Eclipse/ColdFusion Builder. 
    Nancy O.

  • Server 10.5.7 upgrade deleted all user and group Info -- Receiving error -1

    After upgrading our Dual 2.0 G5 server that was running 10.5.6 to 10.5.7 all groups and user information lost access. In addition when starting the workgroup manager error -14008 appears. Also when we look into the console log the following shows up
    ------------com.apple.launchd[1] (edu.mit.kadmind) Throttling respawn: Will start in 10 seconds
    over and over
    Any help would be greatly appreciated.

    I looked into A&I more, maybe it's not as nuclear as I thought. I presumed it meant I needed to reinstall all non-apple Apps, which means digging up disks and codes, none of which I have here. I'm away from home for another 4 weeks, which means doing that is difficult.
    Being away is also why my back-up is a little out of date, I didn't bring the time machine drive for that MBP with me. I had it shipped to me as soon as I had problems, but the back-up I'd have to roll back to is now 1-2 weeks old and might still have the funky user:group problems since my timezone problems began before the 10.5.7 update.
    I think DiskWarrior may of finally repaired the user:group issues. Not 100% sure but it's looking better. I just noticed that the primary user is admin but User is 502 and Group is 502. Whereas my secondary user account (also Admin) on that MBP User is 501 and Group is 20. My recollection is 20 is staff and both users groups should be 20.
    I'll look into A&I more, probably do it when I get home.
    Thanks.
    Message was edited by: jb510

  • User and Group Preferences pane error

    I am having difficulty with the Users and Groups in Lion.  I did not notice this problem. I can add any users. When I click on users it simply gives t=me the message that It cant open the Users preference pane. Any Ideas?

    Launch the Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ If you’re running Mac OS X 10.7 or later, open LaunchPad. Click Utilities, then Terminal in the page that opens.
    Drag or copy – do not type – the following line into the Terminal window, then press return:
    dscl . -list /Users | grep Guest
    Post the lines of output that appear below what you entered, if any – the text, please, not a screenshot.

  • Users and Group preference pane error

    This  crap keeps popping up when i try to access to user and group. I nee dthe solution asap before the March holidays ends. Thanks.

    Launch the Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ If you’re running Mac OS X 10.7 or later, open LaunchPad. Click Utilities, then Terminal in the page that opens.
    Drag or copy – do not type – the following line into the Terminal window, then press return:
    dscl . -list /Users | grep Guest
    Post the lines of output that appear below what you entered, if any – the text, please, not a screenshot.

  • Please Help, After Kernel panic restart failed- apple swirl(6 hrs), SafeMode-failed, SUMode-sucess. Could not unmount disk to erase. Repair permissions-multiple fail errors:unable to set permissions on... unable to set owner and group...

    Please Help, I deleted an account that was the same name as the administrator but was not the administrator. Also a samsung galaxy s phone was charging through the usb port.
    I closed out a program and got a message that the temp file could not be stored/saved.
    Then a Kernel panic message occurred and restart was necessary.
    The restart resulted in the screen with the apple logo and a continous swirl for 6+hrs,
    Attempted Safe Mode start up, unsuccessful,
    Single User Mode-sucess.
    Ran $ fsck_hfs -rfd /dev/disk0s2 Ran several times repairs made with one which remained. something about a node.
    No change in start up attempts
    Started with install CD matching current OS 10.6
    Ran Disk Utility Repair Permissions resulting in multiple errors:
    One line/error
    Warning: SUID file /////Ardagent has been modified and will not be repaired
    144 lines/errors of this type of series of lines
    Group permissions differ on...should be drwxr-xr-x, they are -rw-r--r-- .
    permissions differ on...should be drwxr-xr-x, they are -rw-r--r-- .
    unable to set owner and group...error 22: Invalid Argument
    unable to set permissions on...error 22: Invalid Argument
    Ran Repair Disk, result:
    Error: Could not unmount disk (in red)
    Ran Verify Disk, result:
    The volume HD appears to be ok (in green)
    Next I attempted to erase the dist to start from scratch since I have data backed up on time machine.
    Error message box
    Volume Erase failed
    Volume Erase failed with error:
    Could not unmount disk
    I am looking to solve without buying DiskWarrior unless only resort.

    So it looks like  solved it for now I will update later. What I did was after starting from the install cd for the 10.6 system I ran from terminal ran:
    diskutil disablejournaling /dev/disk0s2
    diskutil disableownership /dev/disk0s2
    diskutil repairPermissions /dev/disk0s2
    then i closed terminal and then when to disk utility and chose to repair disk with results all was fine. Then ran repair permissions and got similar results from terminal function next I erased disk and then chose to restore from time machine and it is now restoring! yea!

  • Cannot transport from quality to production due to syntax error

    Hi all,
    I have modified the program in Development system in which i have added on field to the internal table structure. Internal table is declared in the top include of the program. Now the program is transported to the Quality server which ends with the error for top include as"Original object cannot be replaced". But when i check the top include in quality server, the field which i have added is available. Now for transporting to production server, it ends by syntax error saying "The data object ITAB does not have a component called <field>".
    Please guide me for the above error.
    Thanks & Regards
    Akshay Korade

    >
    Akshay Korade wrote:
    > The production system contains the version before the changes and the error comes while transporting to production system. So the changes are not reflected in the production system.
    I've been doing SAP for a while and I can tell you, definitively, that syntax errors do not prevent import.
    >All the includes are activated and free from syntax errors in quality system.
    >Now for transporting to production server, it ends by syntax error saying "The data object ITAB does not have a component called <field>".
    If there are no syntax errors in quality, then where is that syntax error showing?  It must be in production.  It will be an inactive version in production that has the syntax error.  Go into production, try to activate the program.  Activation will fail because of the syntax error.
    You get the syntax error because the defintion has not made it into P.  If you transport the whole program, as R3TR PROG zprog, and have the correct flags set on import to overcome the message "Original object cannot be replaced", then your problem will be solved.
    matt

  • Windows 7 DNS and Group Policy Issues

    Hi,
    We have several suites of Windows 7 domain connected PC's.
    In one of the suites I have been called into look at 3 different PC's where the users have not got mapped drives, desktop backgrounds, internet connectivity - because their group policies have not applied.
    When I look at the error logs I find DNS 1014 errors, and Group Policy 1054 errors.
    I have looked at the logs on the switches, and there is nothing on them - Could a pupil pulling the network cable out cause these errors?... Possibly they could have put it back in before I got back in the room.
    The user logs off of the PC and back on again and are fine, as are the users that logon after them.
    We have 2 DC's/DNS servers, which I would have thought would be able to cope with the load here.
    Please let me know what you think the likely cause could be.

    Hello John555444,
    What is your current situation?
    Is this issue resolved?
    Best regards,
    Fangzhou CHEN
    Fangzhou CHEN
    TechNet Community Support

  • No syntax errors in a sql query

    Hello,
    We are trying to eliminate Toad from our Standards. One of our people did a test for me to decided weather or not to go with SQL Developer. He compared TOAD with SQL Developer & SQL Plus. He intentially put select * ffrr table_name; to see if it would throw an error. TOAD gave an ORA-00923, SQL Plus gave the same, SQL Developer did not give anything but ran the sql. If I tell users to use this product and they are not exactly familiar with sql and they had syntax errors they wouldn't know if the sql ran properly or not.
    Is there a work around. My company will not provide any more TOAD licenses. I'm trying to find a solution for helping our users do their job but get the right results. Any suggestions would be welcome. This product is still new to me. They bought the DBA's the licenses we need but came up short for the end users.
    Thanks
    CJ

    When I try to run
    select * ffrr dual;in SQL Developer 1.2.1 (3200), I get an alert box reporting an ORA-00923 error. Does this not happen on your machine?

  • Syntax error caused by duplicate methods in class.

    We've applied service patches to CRM 7 and afterwards I found that there were two versions of a method in a class. There was the original (shown in blue) which should point to the superclass, but does not and point to the ZL.... class. Then there's the second copy of the method, shown in black, which is the Redefined method. But, I have never seen both in existance at the same time when view via se24 or the component workbench.
    This is what I have tried:
    Redefined the method (shown in blue). But then I have two methods of the same name (SET_COUNTRY)  both shown in black. If I reverse the redefiniation it does successfully remove one of the redefintions, so I'm back to the state that started with, having the origianl superclass method and its redefiinition present. 
    This problem is in out QAS environment. I corrected this issue in DEV by deleting the Redefined method. However, the transport created fails when moved into QAS and gives a syntax error saying that duplicate methods exist, or is called twice. Which happens to be the problem that the transport should fix.
    Can anyone suggest anything to try and fix this?.
    As a last resort I opened our QAS envirnment for changes and within SE24 choose the option Utilities/Check.... But this did not resolved anything as all the sub-options said that everything was okay.
    Desperate now, the ledge of this window is not very wide but it's starting to look appealing, even though the building is only one storey high.
    [RESOLVED]
    My sanity is restored. No matter what I tried I could not get a transport through to correct this issue. In the end I had to open up QAS for changes and delete the redefined method from ZL... class by commenting out the call statement, and then answer yes to the question 'Do you want to delete the method?'. After this I re-activated all and the WebUI now works okay.
    The trouble is I'll need to repeat this process in production after the upgrade.
    When the problem was fixed in DEV a transport was created, but this just gave an error 8 when imported into QAS. The message given was exactly the problem that it was trying to fix.
    Jason
    Edited by: Jason Stratham on Sep 14, 2010 3:10 PM

    I think you should ask this on the ML or open a feture request on the bugtracker.

  • Syntax error in Numbers.

    I try typing in this "=4,67+log(A2/(24,63-A2))" and get a syntax error.

    Update.
    Which LOG function do you mean? From the Function Button in Numbers:
    Choose Show Function Browser.
    The LOG function returns the logarithm of a number using a specified base.
    LOG(pos-num, base)
    pos-num:  A positive number. pos-num is a number value and must be greater than 0.
    base:  An optional value specifying the base of the logarithm. base is a number value and must be greater than 0. If base is 1, a division by zero will result and the function will return an error. If base is omitted, it is assumed to be 10.
    The LOG10 function returns the base-10 logarithm of a number.
    LOG10(pos-num)
    pos-num:  A positive number. pos-num is a number value and must be greater than 0.
    The LN function returns the natural logarithm of a number, the power to which e must be raised to result in the number.
    LN(pos-num)
    pos-num:  A positive number. pos-num is a number value and must be greater than 0.
    From the Help Menu in Numbers, download the Numbers User Guide and the Formulas and Functions User Guide.
    Regards,
    Ian.

  • CS5 goto Syntax Error

    With the introduction of PHP 5.3, the powers that be introduced a new operator, "goto."  See it in the manual here:
    http://php.net/manual/en/control-structures.goto.php
    Example:
    <?php
    goto a;
    echo 'Foo';
    a:
    echo 'Bar';
    ?>
    Outputs Bar.
    It's really quite handy.
    However, Dreamweaver CS5 does not recognize this instruction and displays a syntax error where it both installed and at the target.
    Is there a workaround or a way to add the tag to the application?

    Thanks, I had re-written and seem to have it working ok but went back to original to test using string instead of text and that seems to work.
    Thanks again for the help.
    Joe

  • Tween/Transition import code gives a syntax error

    Basicly, I'm using Tweens and transitions, and am having
    trouble making them appear in some parts.
    On a multipage website, pasting in the code:
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    Gives me a syntax error for where the two lines appear. -
    This will make any transitions and tweens not appear (the two lines
    above need to be commented out for it to compile). However, when a
    page is loaded that contains the code (and gives no syntax error),
    the transitions and tweens in the first movie as well as the loaded
    clip all work fine.
    What would cause a synax error when trying to use the import
    code?
    The actual site itself you can see in progress at
    http://cressaid.brettjamesonline.com/us
    . The drop down menus just appear, until you load either the logos,
    corporate id or brochures section in folio. Then they smoothly roll
    down

    SuperRoach,
    > I think I found the solution - which was to use
    Actionscript 2.0
    > in the publish settings. This got rid of the error, and
    made it
    > work fine.
    Yes, that makes sense, then. You can look up these classes
    and
    keywords, by the way, in the ActionScript 2.0 Language
    Reference and
    Components Language Reference. Both sets of documentation
    indicate the
    availability of everything you look up. For example, the
    "import statement"
    entry says:
    Availability: ActionScript 2.0; Flash Player 6
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • Prgm /FM to check syntax errors of list of prgms

    Hi All,
    Is there any program/report/function module or any other means to check and list the syntax errors of a list of programs?
    Thank You.
    Regards,
    Soumya

    Hi,
    Try this statement SYNTAX-CHECK
    Go through this documentation
    [Syntax Check|http://help.sap.com/abapdocu_70/en/ABAPSYNTAX-CHECK_FOR_ITAB.htm]
    Alternatively , you can also try this FM EXTENDED_PROGRAM_CHECK.
    Regards,
    Lakshman.

Maybe you are looking for

  • I have Mac OS X 10.5.8, what do I need to do to be able to be able to install itunes 11.1?

    I have Mac OS X 10.5.8, what do I need to do to be able to be able to install itunes 11.1?

  • List of Oracle Reports run through Oracle Portal.

    Hi, It's possible that I am posting my message to a wrong Forum. If that's so, please let me know (and the correct forum too). I have several Oracle Reports that are run through Oracle Portal (when user clicks a link for a report). I want to get a li

  • Adding new feilds in WEB UI

    Hello All, When a new field is added in WEB UI 7.0 does it create same field in the backend (GUI)? For example if I add XYZ filed in service transaction is the same field replicated on GUI.

  • Mrp control parameter- neupl

    Hi, pls advise is it necessary to use newpl control parameter to run the mrp first time in any plant after cutover activities updation? incase if we run with netch, what will happen? any problem will arise. pls guide.

  • Configuring titlebar info order

    I'm searching for a way to switch titlebar-information in x11-windows from "document title - application name" the other way round: "application name - document title". I'm using xfce right now, but the default seems to be the same in gnome as well.