DBAsupport.com Forums - Powered by vBulletin
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: ORA-00936 with Oracle script

  1. #1
    Join Date
    Oct 2008
    Location
    Midrand, South Africa
    Posts
    14

    Question ORA-00936 with Oracle script

    When run the following script returns an ORA-00936 missing expression error.
    Code:
    select  mem_number AS MemNumber,
            sum(trans_turnover) AS Turnover
    from members
    join transact
    on mem_number = trans_code
    where Trans_date between '01-Jan-2004' and '09-Oct-2008'
    and mem_barred = 0
    group by mem_number,
            order by turnover desc
    )
    where rownum <=200;
    Please tell me what I have done wrong and how do I fix this.

  2. #2
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Two thing pop up...

    1- You are missing a...

    select *
    from
    (


    ...at the beginning of your script.

    2- You want to do "where rownum < 201;"
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  3. #3
    Join Date
    Oct 2008
    Location
    Midrand, South Africa
    Posts
    14

    ORA-00936 with Oracle script

    I do not understand how one would incorporate the select * from (
    and I do not see too much difference between rownum < 201 and rownum <= 200

    Please give me more detail.

  4. #4
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Quote Originally Posted by straygrey
    I do not understand how one would incorporate the select * from (
    and I do not see too much difference between rownum < 201 and rownum <= 200

    Please give me more detail.
    Don't worry, I got there are a lot of things you are not understanding, try this

    Code:
    select *
    from
    (
    select  mem_number AS MemNumber,
            sum(trans_turnover) AS Turnover
    from members
    join transact
    on (mem_number = trans_code)
    where Trans_date between '01-Jan-2004' and '09-Oct-2008'
    and mem_barred = 0
    group by mem_number,
    order by turnover desc
    )
    where rownum < 201;
    Last edited by PAVB; 10-10-2008 at 10:05 AM.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  5. #5
    Join Date
    Oct 2008
    Location
    Midrand, South Africa
    Posts
    14

    ORA-00936 with Oracle script

    I tried your suggestions and still get the same error message.

  6. #6
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Okay...

    Would you please post DESC of both tables as well as complete sql*plus session showing the error?
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  7. #7
    Join Date
    Nov 2000
    Location
    Baltimore, MD USA
    Posts
    1,339
    Code:
    group by mem_number, <--- Remove this comma
    Christopher R. Long
    ChrisRLong@HotMail.Com
    But that's just my opinion. I could be wrong

  8. #8
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166
    Quote Originally Posted by chrisrlong
    Code:
    group by mem_number, <--- Remove this comma
    Chrisrlong, as usual, is correct.

  9. #9
    Join Date
    Oct 2008
    Location
    Midrand, South Africa
    Posts
    14

    ORA-00936 with Oracle script

    I have now got the code to look like
    Code:
    select * from 
    (
    mem_number AS MemNumber,
    sum(trans_turnover) AS Turnover
    from members
    join transact
    on mem_number = trans_code
    where Trans_date between '01-Jan-2004' and '09-Oct-2008'
    and mem_barred = 0
    group by mem_number
    order by turnover desc 
    ) 
    where rownum <=200;
    and now the error I get is ORA-00907: missing right parenthesis.
    Help again please.

  10. #10
    Join Date
    Oct 2008
    Location
    Midrand, South Africa
    Posts
    14
    Changing my script to:-
    Code:
    select MemNumber,Turnover
    from
    (
    select  mem_number MemNumber,
            sum(trans_turnover) Turnover
    from members
    join transact
    on mem_number = trans_code
    where Trans_date between '01-Jan-2004' and '09-Oct-2008'
    and mem_barred = 0
    group by mem_number
    order by turnover desc 
    ) 
    where rownum <=200;
    caused it to work. Thank you for all your suggestions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width