2

I am newbie with oracle DB and I need to List the Number of departments per region in the region table.

This is my SQL statement:

 select r.region_id, count(d.department_id) "Number of Department"
 from region r, department d
 where r.region_id = d.region_id
 group by r.region_id

I am getting this error:

ORA-00904: "D"."region_id": invalid identifier

How can I correct this error?

miracle173
7,79728 silver badges42 bronze badges
asked Feb 18, 2016 at 7:40
1
  • Use quotes on columns names in all your select Ex. r."region_id"=d."region_id" Commented Dec 3, 2019 at 19:27

1 Answer 1

1

When ORA-00904: invalid identifier occurs, we must enter a valid column name as it is either missing or the one entered is invalid. This error most commonly happens when we are referencing an invalid alias in a select statement. Oracle's voice on ORA-00904 error:

ORA-00904 string: invalid identifier

Cause: The column name entered is either missing or invalid.

Action: Enter a valid column name. A valid column name must begin with a letter, be less than or equal to 30 characters, and consist of only alphanumeric characters and the special characters ,ドル _, and #. If it contains other characters, then it must be enclosed in double quotation marks. It may not be a reserved word.

To avoid ORA-00904, column names must

  • begin with a letter.
  • consist only of alphanumeric and the special characters ($_#); other characters need double quotation marks around them.
  • be less than or equal to thirty characters.

  • answered Feb 21, 2016 at 1:31
    0

    Your Answer

    Draft saved
    Draft discarded

    Sign up or log in

    Sign up using Google
    Sign up using Email and Password

    Post as a guest

    Required, but never shown

    Post as a guest

    Required, but never shown

    By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.