Pivot gives invalid identifier query

I am trying to create my first pivot query. I have two tables:

CREATE TABLE "SKIP"."ORDERS"    
(
  "CATG" VARCHAR2(30),
   "PART_NR" VARCHAR2(30),
   "PART_REV" VARCHAR2(30),
   "CUST_ID" NUMBER,
   "ORDER_DT" DATE )
;


CREATE TABLE "SKIP"."CUSTOMERS"    
(
  "STATE" VARCHAR2(30),
   "CUST_ID" NUMBER    )
;

I want to create a PivotTable with years above and some of the numbers on the side. I had a problem from the beginning when I tried it. It seems that you can't use a function on the clause, which forbids me to use

PIVOT (COUNT (PART_NR) to extract (year of the ORDERS.) ORDER_DT))

I don't remember the exact error, he gave me, but I found a "possible solution" with the query nested that I have below

SELECT * FROM
(SELECT PART_NR, YR FROM (
  (SELECT ORDERS.CATG || '-' || ORDERS.PART_NR || ORDERS.PART_REV AS PART_NR, extract (year from ORDERS.ORDER_DT) AS "YR"
  FROM ORDERS, CUSTOMERS
  where
  CUSTOMERS.STATE = "VA"
  and 
  ORDERS.CUST_ID = CUSTOMERS.CUST_ID
  )
)
PIVOT (COUNT(PART_NR) FOR YR IN (
  2002,
  2003,
  2004,
  2005,
  2006,
  2007,
  2008,
  2009,
  2010,
  2011,
  2012,
  2013
  )
)
)
ORDER BY PART_NR

But now, I get an error: 'Year': invalid identifier

I tested the two nested queries (beginning with SELECT PART_NR, YR OF) and who did indeed get the two columns PART_NR and year, so the problem must be in the PIVOT.

Any ideas?

Hello

You probably mean COUNT (*) instead of COUNT (part_nr) and use SELECT * in the subquery, which is the PIVOT.

There is a column called GOING? If this isn't the case, you probably want to single quotes, not double - quote, in line 6.

2 external queries can be combined; You can make an ORDER BY in the query even as PIVOT.

If I had copies of sample size of your tables, and the results you wanted Sinc sample data, then I could test and show you exactly.

Whenever you have a problem, please post a small example data (CREATE TABLE and only relevant columns, INSERT statements) of all the tables involved, so that people who want to help you can recreate the problem and test their ideas.

Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.

Always say what version of Oracle you are using (for example, 11.2.0.2.0).

See the FAQ forum: https://forums.oracle.com/message/9362002

Tags: Database

Similar Questions

  • Subqueries, addressing deep gives ORA-00904: invalid identifier

    Why the following query gives the error:
    with T as
    (
     select 1 ID from dual union all
     select 2 ID from dual
    )
    select ID from T
    where 1 = (
       select Cnt from
          (
           select count(*) Cnt
           from T innerT
           where innerT.ID = T.ID
          )
    )
    /*ORA-00904: "T"."ID": invalid identifier*/
    ;
    But this query succeeds:
    with T as
    (
     select 1 ID from dual union all
     select 2 ID from dual
    )
    select ID from T
    where 1 = (   
          select count(*) Cnt
          from T innerT
          where innerT.ID = T.ID
          )
    /*1
    2*/
    ;
    Why the first query gives grammatice "error? There in one addressing deep enough level to the outside world, which seems to be a problem:
    innerT.ID = T.ID
    Can you explain why such a thing is not allowed?

    Hello

    I think it's because correlated subqueries cannot be nested rather than on a single level.
    The inner query external very table T is 2 levels.

    In the second case, there only one & level between inner query and table T, so it works.

    I'll try to find some useful links to this topic...

    And here's one:
    AskTom

    Published by: Nicosa 31 May 2010 06:02
    (I can't get the link to display correctly...)

    Published by: Nicosa 31 May 2010 06:02

  • Subselect query returns "invalid identifier", but the nested query return lines

    I don't think it's a general SQL question.

    Select * from persons where person_id in)

    Select person_id with people whose name = 'Obama' - subquery

    ) and age > 18;

    When I run the subquery, I get:

    ORA-00904: "PERSON_ID": invalid identifier

    00904, 00000 - '% s: invalid identifier '.

    * Cause:

    * Action:

    Error on line: column 5: 8

    This is because the table people do not have the person_id field.

    But when I run the nested together query it returns all the lines in people with the AGE greater than 18.

    How is he succeeds when the subquery is obviously wrong?

    363f652b-263D-4418-933F-74a1d0a41b4c wrote:

    I don't think it's a general SQL question.

    Select * from persons where person_id in)

    Select person_id with people whose name = 'Obama' - subquery

    ) and age > 18;

    When I run the subquery, I get:

    ORA-00904: "PERSON_ID": invalid identifier

    00904, 00000 - '% s: invalid identifier '.

    * Cause:

    * Action:

    Error on line: column 5: 8

    This is because the table people do not have the person_id field.

    But when I run the nested together query it returns all the lines in people with the AGE greater than 18.

    How is he succeeds when the subquery is obviously wrong?

    Yes - this is a general SQL question and ask often enough.

    Correlated subqueries depend on the inner query, be able to see and access to the columns of the outer query. Normally see you referenced in the WHERE clause of the subquery and not in the SELECT clause, but the reference is valid in both places. This works because the columns of the tables in the main query are accessible in the subquery. "Person_id" is probably a column in the table 'people '.

    Which can be a cause of problems 'odd' when the column (in your case "person_id") is more of a table.

    Use an alias in the subquery in the subquery and you will find that it will not succeed.

    See these two articles AskTom where he addresses this specific issue

    http://asktom.Oracle.com/pls/Apex/f?p=100:11:0:P11_QUESTION_ID:3317493900346468494

    http://asktom.Oracle.com/pls/Apex/f?p=100:11:0:P11_QUESTION_ID:155200640564

  • ISSUES giving invalid identifier

    Hello

    Under query me gives error invalid identifier.

    Can someone please make an eyeball and let me know any correction on the underside of sql?

    SELECT case_id

    OF form_product A

    WHERE ud_text_12 LIKE '% % '.

    AND THERE ARE

    (

    SELECT case_id

    OF form_product B

    WHERE ud_text_12 LIKE ' % of DRUGS. "

    )

    AND A.CASE_ID = B.CASE_ID

    SQL error: ORA-00904: "B". "" CASE_ID ": invalid identifier

    00904, 00000 - '% s: invalid identifier '.

    * Cause:

    * Action:

    Thank you

    Ann

    I guess you mean:

    SELECT case_id

    OF form_product A

    WHERE ud_text_12 LIKE '% % '.

    AND THERE ARE

    (

    SELECT case_id

    OF form_product B

    WHERE ud_text_12 LIKE '% DRUG' AND A.CASE_ID = B.CASE_ID

    )

  • Invalid identifier

    During execution of the query below, I get ORA-00904 as invalid identifier error.

    But when I execute view inline that it gives the result.

    I'm giving all types of data correctly.

    Select
    EMP_QUERY. "' Empno ' EMPNO,.
    EMP_QUERY. "' Ename ' ENAME,
    EMP_QUERY. """" "Job",
    EMP_QUERY. "" Bishop "MGR.
    EMP_QUERY. "" HireDate "HIREDATE.
    EMP_QUERY. "' SAL ' SAL,
    EMP_QUERY. "Comm"COMM,
    EMP_QUERY. "DEPTNO"DEPTNO ".
    Of(

    Select empno, ename, job, mgr, Hiredate, sal, comm, deptno SRC_1.EMP_SRC_11

    ) EMP_QUERY

    where(1 = 1)

    That's because you specified the column name in the selection external double quotes.

    EMP_QUERY. "' Empno ' EMPNO

    Why does. To take

    emp_query.EmpNo as 'Empno '.

  • ORA-00904: "A". "" LVCI_ISSUEDATE ": invalid identifier

    Hello

    I get (ORA-00904: "A".) ("' LVCI_ISSUEDATE ': invalid identifier) error for the following query...

    SELECT A.lvci_issuedate, A.lvci_lotno, (SELECT B.cot_desc FROM tb_lvm_cottondesc B
    WHERE B.cot_seqno_pk = A.lvci_cottonno) AS cotton.
    A.lvci_nbales, (SELECT C.lvcr_rate FROM tb_lvm_cottonreceipt C WHERE C.lvcr_cottonno = A.lvci_cottonno
    AND C.lvcr_invdate = (SELECT MAX (lvcr_invdate) FROM (SELECT D.lvcr_invdate FROM tb_lvm_cottonreceipt D.lvcr_invdate D WHERE < A.lvci_issuedate))) AS RATE, A.lvci_weight, A.lvci_issuedate tb_lvm_cottonissue A.lvci_issuedate A WHERE BETWEEN to_date (January 12, 2008 ', ' dd/mm/yyyy') AND to_date (June 12, 2008 ', ' dd/mm/yyyy')

    I use Oracle 9i.

    Could you give me solution to this problem? What's not in my sql query?

    Hi psram.

    First bad thing, it's that you format your query in order to make it readable.

    SELECT A.lvci_issuedate
         , A.lvci_lotno
         , (SELECT B.cot_desc
              FROM tb_lvm_cottondesc B
             WHERE B.cot_seqno_pk = A.lvci_cottonno) AS cotton
         , A.lvci_nbales
         , (SELECT C.lvcr_rate
              FROM tb_lvm_cottonreceipt C
             WHERE C.lvcr_cottonno = A.lvci_cottonno
               AND C.lvcr_invdate = (SELECT MAX(lvcr_invdate)
                                       FROM (SELECT D.lvcr_invdate
                                               FROM tb_lvm_cottonreceipt D
                                              WHERE D.lvcr_invdate < *A.lvci_issuedate*))) AS RATE
         , A.lvci_weight
         , A.lvci_issuedate
      FROM tb_lvm_cottonissue A
     WHERE A.lvci_issuedate BETWEEN to_date('01/12/2008', 'dd/mm/yyyy')
                                AND to_date('06/12/2008', 'dd/mm/yyyy');
    

    Then it is nested too deep, I think it's the same thing:

    SELECT A.lvci_issuedate
         , A.lvci_lotno
         , (SELECT B.cot_desc
              FROM tb_lvm_cottondesc B
             WHERE B.cot_seqno_pk = A.lvci_cottonno) AS cotton
         , A.lvci_nbales
         , (SELECT C.lvcr_rate
              FROM tb_lvm_cottonreceipt C
             WHERE C.lvcr_cottonno = A.lvci_cottonno
               AND C.lvcr_invdate = (SELECT MAX(lvcr_invdate)
                                       FROM tb_lvm_cottonreceipt D
                                      WHERE D.lvcr_invdate < A.lvci_issuedate)) AS RATE
         , A.lvci_weight
         , A.lvci_issuedate
      FROM tb_lvm_cottonissue A
     WHERE A.lvci_issuedate BETWEEN to_date('01/12/2008', 'dd/mm/yyyy')
                                AND to_date('06/12/2008', 'dd/mm/yyyy');
    

    Try, but I thing it is always nested deep

    Concerning
    Peter

  • Invalid identifier error using UNION ALL?

    Can someone tell me why it gives me the error: ORA-00904: "Wait_time": invalid identifier.

    It must be something with the UNION ALL because it works fine if I have only one query at a time.

    Thank you
    Deanna



    Select wait_time | ' Minutes.' | «, » || COUNTY (wait_time) under the name of "0 to 10 Min, COUNT"
    Of MOTOR_ASSIST2
    WHERE the wait_time BETWEEN 0 AND 10 and ((: p53_fiscal_yr IS NULL))
    GOLD: p53_fiscal_yr = TO_CHAR (ADD_MONTHS (datetime, 6), "YYYY"))
    OR (: p53_month IS NULL or: P53_month = TO_CHAR (DATETIME, 'MM'))
    (AND (: p53_year IS NULL or: p53_year = TO_CHAR (DATETIME, 'YYYY')))

    UNION ALL

    Select wait_time | ' Minutes.' | «, » || COUNTY (wait_time) under the name of "11-30 Min, COUNT.
    Of MOTOR_ASSIST2
    where wait_time BETWEEN 11 AND 30 and ((: p53_fiscal_yr IS NULL))
    GOLD: p53_fiscal_yr = TO_CHAR (ADD_MONTHS (datetime, 6), "YYYY"))
    OR (: p53_month IS NULL or: P53_month = TO_CHAR (DATETIME, 'MM'))
    (AND (: p53_year IS NULL or: p53_year = TO_CHAR (DATETIME, 'YYYY')))

    UNION ALL

    Select wait_time | ' Minutes.' | «, » || COUNTY (wait_time) under the name of "31-60 Min, COUNT.
    of MOTOR_ASSIST2
    where wait_time BETWEEN 31 AND 60 and ((: p53_fiscal_yr IS NULL))
    GOLD: p53_fiscal_yr = TO_CHAR (ADD_MONTHS (datetime, 6), "YYYY"))
    OR (: p53_month IS NULL or: P53_month = TO_CHAR (DATETIME, 'MM'))
    (AND (: p53_year IS NULL or: p53_year = TO_CHAR (DATETIME, 'YYYY')))

    UNION ALL

    Select wait_time | ' Minutes.' | «, » || (WAIT_TIME) count as '61 Min + COUNT.
    of MOTOR_ASSIST2
    where wait_time BETWEEN 61 AND 1000 and ((: p53_fiscal_yr IS NULL))
    GOLD: p53_fiscal_yr = TO_CHAR (ADD_MONTHS (datetime, 6), "YYYY"))
    OR (: p53_month IS NULL or: P53_month = TO_CHAR (DATETIME, 'MM'))
    (AND (: p53_year IS NULL or: p53_year = TO_CHAR (DATETIME, 'YYYY')))


    WAIT_TIME GROUP
    ORDER BY WAIT_TIME;

    And if you want to be really want...

    SQL> ed
    Wrote file afiedt.buf
    
      1  WITH c1 as (select row_number() over (order by sal) as rn
      2                    ,SAL||':'||COUNT(*) "SAL0-999"
      3              from emp
      4              where sal between 0 and 999
      5              group by sal)
      6      ,c2 as (select row_number() over (order by sal) as rn
      7                    ,SAL||':'||COUNT(*) "SAL1000-1999"
      8              from emp
      9              where sal between 1000 and 1999
     10              group by sal)
     11      ,c3 as (select row_number() over (order by sal) as rn
     12                    ,SAL||':'||COUNT(*) "SAL2000-2999"
     13              from emp
     14              where sal between 2000 and 2999
     15              group by sal)
     16      ,c4 as (select row_number() over (order by sal) as rn
     17                    ,SAL||':'||COUNT(*) "SAL3000-3999"
     18              from emp
     19              where sal between 3000 and 3999
     20              group by sal)
     21      ,c5 as (select row_number() over (order by sal) as rn
     22                    ,SAL||':'||COUNT(*) "SAL4000+"
     23              from emp
     24              where sal >= 4000
     25              group by sal)
     26  select "SAL0-999", "SAL1000-1999", "SAL2000-2999", "SAL3000-3999", "SAL4000+"
     27  from c1 FULL OUTER JOIN c2 ON (c2.rn = c1.rn)
     28          FULL OUTER JOIN c3 ON (c3.rn = COALESCE(c1.rn, c2.rn))
     29          FULL OUTER JOIN c4 ON (c4.rn = COALESCE(c1.rn, c2.rn, c3.rn))
     30          FULL OUTER JOIN c5 ON (c5.rn = COALESCE(c1.rn, c2.rn, c3.rn, c4.rn))
     31* order by 1,2,3,4,5
    SQL> /
    
    SAL0-999       SAL1000-1999   SAL2000-2999   SAL3000-3999   SAL4000+
    -------------- -------------- -------------- -------------- --------------
    800:1          1100:1         2450:1         3000:2         5000:1
    950:1          1250:2         2850:1
                   1300:1         2975:1
                   1500:1
                   1600:1
    
    SQL>
    

    Published by: BluShadow on November 7, 2008 15:47
    Elimination of unnecessary case statements

  • Suspended blackBerry smartphones. Reason: 116 - invalid identifier

    Hello everyone,

    I hope someone here can help me.

    My Blackberry Curve stopped receives or sends data communications last night.  My provider (Rogers) service troubleshooting-the question down to the RIM servers.  Rogers stated that they could not access the envirnoment RIM to fix this and they gave me a phone number.  1 800 327 - 9085

    Looks like I have to pay for a support call to get my Blackberry restored. It's obviously ridiculous since it was no fault of mine that this problem has occurred.

    Error message: Suspended. Reason: 116 - invalid identifier

    How can I solve this?

    Thank you

    Reminder of Rogers and ask (ask politely) that your question be wound to RIM tech support level, free of charge. They will do it. There is no reason for you to pay for per-incident support.

    Rogers wouldn't you give no reason for the suspension?

    Which has been suspended, your Rogers account, your PIN, your what?

  • ORA-00904: "DATA". "" AM ": invalid identifier

    Hello
    I am facing upwards a situation I can't find why is the error ora-00904 appears.
    I wrote the request as follows:

    (A)

    with data as
      (
      select uc.* 
        from user_computer uc
         where computer_name like '%'||:perioxi||'%'
      )
      select uc.* 
        from user_computer uc
        where exists (select 1
                       from data
                       where data.am = uc.am)
         and exists (select 1
                          from v_misthotoi_orga
                          where uc.am = v_misthotoi_orga.matr) 
    

    Where the utilisateur_ordinateur is a table, and the v_misthotoi_orga is a db view (a view that is based on another view that is based on a table that is accessed through a dblink).
    A query runs without error.

    (B)

    with data as
      (
      select uc.* 
        from user_computer uc
         where computer_name like '%'||:perioxi||'%'
      )
      select uc.* 
        from user_computer uc
        where exists (select 1
                       from data
                       where data.am = uc.am)                       <.... THE DATACOLUMN DATA.AM IS USED, WITHOUT ERROR                
         and exists (select 1
                          from v_misthotoi_orga
                          where data.am = v_misthotoi_orga.matr)    <.....THIS IS WHERE THE ERROR IS LOCATED (DATA.AM)
    

    The above query (application B) stops with error: ORA-00904: "DATA". "" AM ": invalid identifier.

    You can identify the cause of the error, since the datacolumn 'am' in 'data' datasource is used twice in query B.
    In the first instance without any error in the second with the error.

    Note: Oracle db v.2
    Thank you
    SIM

    Hey Sim,

    Change

    select 1
    from v_misthotoi_orga
    where data.am = v_misthotoi_orga.matr
    

    TO

    select 1
    from v_misthotoi_orga,
           data  
    
    where data.am = v_misthotoi_orga.matr
    

    In this query, Oracle knows no data unless you specify in the From clause that he should use.

    HTH,

    Stefan

  • ORA-00904: "YYYY": invalid identifier using impdp

    Hello

    I am trying to import a part of a table to another table on the remote database using impdp:

    Impdp directory of centrumadmin/centrumadmin = network_link DUMP_LOG_DIRECTORY LOGFILE = backup_2014_01.log = REF2ISKNE = 'AUD$ _BACKUP' content TABLES = QUERY DATA_ONLY =------"WHERE \" NTIMESTAMP # "> to_date\ (January 2, 2014","DD-MM-YYYY '------") "------"; "

    But still get this error:

    Start "CENTRUMADMIN". "' SYS_IMPORT_TABLE_01 ': centrumadmin / * directory = network_link DUMP_LOG_DIRECTORY LOGFILE = backup_2014_01.log = REF2ISKNE TABLES = AUD$ happy _BACKUP = DATA_ONLY QUERY =" WHERE NTIMESTAMP # > to_date (02-2014, MM-YYYY) ""

    Current estimation using BLOCKS method...

    Processing object type TABLE_EXPORT/TABLE/TABLE_DATA

    Total estimation using BLOCKS method: 4,473 GB

    ORA-31693: Data Table object 'CENTRUMADMIN '. "" AUD$ _BACKUP "could not load/unload and being ignored because of the error:

    ORA-00904: "YYYY": invalid identifier

    Work "CENTRUMADMIN". "" SYS_IMPORT_TABLE_01 "completed with error (s 1) to Wed Feb 11 09:32:15 2015 elapsed 0 00:00:03

    Any ideas? If I change the date format YYYY-MM-DD or the other, always error is in the last part: ORA-00904: "DD": invalid identifier.

    Thank you.

    Honza

    Hi Mika,

    have you played around with some double 'or triple?

    as

    to_date\ ("02/01/2014","DD-MM-YYYY"------)-«;»

    concerning

    Kay

  • ORA-00904: "PCT_DB_TIME": invalid identifier

    Hello

    on 11.2.0.4 on Win 2008

    I got when running:

    SQL > SELECT EVENT, n.WAIT_CLASS,.

    TIME_WAITED_MICRO, ROUND(TIME_WAITED_MICRO*100/S.DBTIME,1) 2 PCT_DB_TIME

    3. IN V$ SYSTEM_EVENT E, V$ EVENT_NAME N,.

    4 (SELECT the DBTIME OF the V VALUE $ SYS_TIME_MODEL WHERE STAT_NAME = 'DB time') S

    5. WHERE E.EVENT_ID = N.EVENT_ID

    6 AND N.WAIT_CLASS NOT IN ('inactive', ' E/s system') and PCT_DB_TIME <>0

    7 ORDER BY PCT_DB_TIME ASC;

    AND N.WAIT_CLASS NOT IN ('inactive', ' E/s system') and PCT_DB_TIME <>0

    *

    ERROR on line 6:

    ORA-00904: "PCT_DB_TIME": invalid identifier

    Thanks for the help.

    This is an invalid identifier because you cannot use a column assigned in the application to the location alias WHERE clause or ORDER BY in the same query.  You have two options to rewrite this query:

    SELECT EVENT, n.WAIT_CLASS,
    TIME_WAITED_MICRO, ROUND(TIME_WAITED_MICRO*100/S.DBTIME,1) PCT_DB_TIME
    V $ SYSTEM_EVENT E, V$ EVENT_NAME N,.
    (SELECT the DBTIME VALUE OF V$ SYS_TIME_MODEL WHERE STAT_NAME = "DB time") S
    WHERE E.EVENT_ID = N.EVENT_ID
    AND N.WAIT_CLASS NOT IN ('Idle', ' E/s system') and ROUND(TIME_WAITED_MICRO*100/S.DBTIME,1) <> 0
    ORDER BY ROUND(TIME_WAITED_MICRO*100/S.DBTIME,1) ASC;

    and

    SELECT * from
    (SELECT EVENT, n.WAIT_CLASS,
    TIME_WAITED_MICRO, ROUND(TIME_WAITED_MICRO*100/S.DBTIME,1) PCT_DB_TIME
    V $ SYSTEM_EVENT E, V$ EVENT_NAME N,.
    (SELECT the DBTIME VALUE OF V$ SYS_TIME_MODEL WHERE STAT_NAME = "DB time") S
    WHERE E.EVENT_ID = N.EVENT_ID
    AND N.WAIT_CLASS NOT IN ('Idle', ' E/s system'))
    where PCT_DB_TIME <> 0
    ORDER BY PCT_DB_TIME ASC;

    Both work.

    David Fitzjarrell

  • PL/SQL: ORA-00904: invalid identifier (DG4ODBC 11.2.0.2 &amp; MySQL)

    I have a PL/SQL script, processing of information between Oracle and MySQL databases. My script runs perfectly with DG4ODBC 11.1.0.7. Then we went from Oracle 10.2.0 and 11.2.0.2 DG4ODBC. Now, if I run my script from command line Solaris love. / myscript.shl, I get the following errors:

    PL/SQL: ORA-00904: "cmswhit_moodle1." "" "" mdl_grade_grades "." finalgrade ": invalid identifier.

    PL/SQL: ORA-00904: "cmswhit_moodle1." "" "" mdl_question_states '. "the attempt": invalid identifier "

    The strange thing is that if I run the same query by cut and paste in sqlplus command line, the application works perfectly without any problems.

    What is the cause of this problem?

    Any help would be greatly appreciated.

    Jeffrey

    Hi Klaus,

    The problem has been resolved after I upgraded MySQL ODBC to a new version of 5.1.8 to 5.1.13.

    Summary of the problem and its solution:

    The problem: It seems that dg4odbc 11.2.0.2 requires a newer version of MyODBC. Previously, I used MyODBC 5.1.8, which ran into problems with dg4odbc 11.20.0.2.

    The Solution: After that I upgraded 5.1.13 MyODBC, my PL/SQL scripts all work.

    I need to point out that with that MyODBC 5.1.8, I can run queries and updates to SQL * more console, but now the PL/SQL scripts.

    I'm going to close this message.

    Once again, thank you and happy holidays.

    Jeffrey

  • HELP: instr() error - invalid identifier

    Hello

    Query is attack on this line:

    instr(hntl.note_text, "Critical and/or Actionable") != 0
    

    Error:

    ORA-00904: "criticism and/or action": invalid identifier

    00904, 00000 - '% s: invalid identifier '.

    note_text column is of type varchar (2000)

    How can I make this work?

    Hello

    In Oracle SQL, string literals are enclosed in single quotes, not double - quote.  You probably want to

    ... instr (hntl.note_text, "Criticism and/or Actionable")! = 0

    Note that SQL differs from SQL * more in this regard.  In SQL * Plus, - single and double quotes are often used interchangeably.  In SQL, they always have a different meaning.

    In Oracle SQL, quotation marks are used in identifiers (such as table names or column) which are not conform to the normal rules of naming.  For example, the column names cannot usually contain special characters such as spaces or slashes (' / ').  If you really want to have a column that is named

    Criticism or action

    you will then need to with the spaces and the bar slash, surround it with quotation marks.  That's exactly what the system thought you were doing: he thought you were trying to refer to a column called 'Critical and/or usable' and, when he couldn't find a column with this name, it gave you an error indicating that the column name was not fair.

  • Invalid identified

    Hi all

    I try to convert my query using the emp table.

    Query

    SELECT empno, ename, JOB,

    (SELECT (CASE sal WHEN > 3000 THEN 999)

    Sal OTHER

    filteredsal end)

    Of

    (

    SELECT sal

    Of inner_emp of the emp

    WHERE inner_emp.empno = outer_emp.empno

    SSS))

    Of outer_emp emp;

    I get the error message

    Error message

    ORA-00904: "OUTER_EMP." "' EMPNO ': invalid identifier

    00904, 00000 - '% s: invalid identifier '.

    * Cause:

    * Action:

    Error on line: column 9:44

    Please help me. I know that outer_emp.empno is out of scope, but how to solve this problem...


    Hello

    This page has a lot of different questions / answers.  Which do you not understand?  You can be more specific, we can be more helpful.  Post a question like "Whn Tome Kyte said... does that mean...?  If so, why it does not work...?  I expect this request to produce... because... »

    The main question and answer, which are relevant to this topic, is that a subquery can be coprrelated to its immediate parent application; No grandparent or distant ancestor.  We will format your query so that it is easier to see:

    SELECT ename, empno, job - it's level 1

    ,      (                                -- Begin Level 2

    SELECT (CASE

    WHEN sal_prev > 2000

    THEN 999

    Of OTHER sal_prev

    END

    ) AS filteredsal

    OF (-start level 3)

    SELECT LAG (sal, 1, 0) OVER (ORDER BY sal) AS sal_prev, sal

    Of inner_emp of the emp

    WHERE inner_emp.empno = outer_emp.empno - this causes the error

    ) - End of level 3

    )                                -- End Level 2

    AS -sss, there is level 1

    The outer_emp emp - is always level 1

    ;

    Tom Kyte said that at level N expressions referenece to the columns of the tables to N-tier and N - 1 only, not level N-2 or an earlier version.  In your code, the statement that caused the error is level 3. You can reference a table friom level 3-1 = 2 at this point, but not outer_emp, which is level 1.

  • invalid identifier of subquery

    Hi all

    I created this application with me, when I run this query, I get a.efg invalid identifier

    [code]

    Select polgm_no, a.abc, a.efg

    of pt_gm_policy.

    (SELECT polgm_no,

    sum (cp_lc_pay_amt) abc

    Of

    pt_gm_claim pt_gm_c,

    pt_gm_claim_paid,

    pt_gm_policy pt_gm_p

    WHERE

    clm_sys_id = cp_clm_sys_id and

    pt_gm_p.POLGM_SYS_ID = pt_gm_c.CLM_POLGM_SYS_ID and

    CLM_POL_NO =' 01/2010/886/3 '

    Union of all the

    SELECT

    polgm_no, efg sum (PR_GROSS_LC_PREM-PR_POLGM_LC_DISC)

    Of

    ps_gm_prem_reg PS_GM,

    pt_gm_policy pt_gm_p

    -pt_gm_claim pt_gm_c

    WHERE

    pt_gm_p.POLGM_SYS_ID = ps_gm. PR_POLGM_SYS_ID AND

    polgm_no =' 01/2010/886/3 ') a

    where pt_gm_policy.polgm_no = a.polgm_no

    and pt_gm_policy.polgm_no='01/2010/886/3'

    [/ code]

    kindly Guide

    thanking in advance

    Lopez

    You must enclose the two results:

    Select a.polgm_no, abc, efg

    (SELECT polgm_no,

    sum (cp_lc_pay_amt) abc

    Of

    pt_gm_claim pt_gm_c,

    pt_gm_claim_paid,

    pt_gm_policy pt_gm_p

    WHERE

    clm_sys_id = cp_clm_sys_id and

    pt_gm_p.POLGM_SYS_ID = pt_gm_c.CLM_POLGM_SYS_ID and

    CLM_POL_NO =' 01/2010/886/3 '

    Polgm_no group) a

    LEFT OUTER JOIN

    (SELECT

    polgm_no, efg sum (PR_GROSS_LC_PREM-PR_POLGM_LC_DISC)

    Of

    ps_gm_prem_reg PS_GM,

    pt_gm_policy pt_gm_p

    -pt_gm_claim pt_gm_c

    WHERE

    pt_gm_p.POLGM_SYS_ID = ps_gm. PR_POLGM_SYS_ID AND

    polgm_no =' 01/2010/886/3 ' group of polgm_no)

    b ON a.polgm_no = b.polgm_no

Maybe you are looking for

  • can assume that new tapes of series 2 will fit original Apple Watch?

    ??

  • Disable the Crash Reporter

    When the browser crashes, it is possible that some of the data from sensitive web applications or sites may be included in a crash report. So some companies want reports disabled if the browser is used to access sensitive data.Except disabling Crash

  • For the Malaysia SkypeIn number?

    Plans to introduce in Malaysia SkypeIn numbers? If not, is there a workaround solution, where I can receive SMS of a Malaysian mobile phone number?

  • WLan is interrupted every 30 min

    Hello! I have the following problem: My Internet connection is cut off about every 30 min, then works again after about 10 to 20 seconds.Why is this? I also during the break seems to connect to the router (at least the transmission rate shows still 1

  • Parameters of the agenda...

    Is it possible to have all the days on the calendar with a white background?  Right now my calendar watch on weekends in white, but in week in gray.  I looked in preferences, but don't see any possibility to change weekends.