Results 1 to 5 of 5

Thread: Invalid identifier

  1. #1
    Join Date
    Aug 2008
    Posts
    2

    Invalid identifier

    I'm having problems with a script containing subqueries. The error is ERROR at line 3:
    ORA-00904: "C"."AMTPID": invalid identifier

    Could someone please let me know what I'm missing?


    select groupid, benpkg,
    medtir, finyer, finper,sum(submed), sum(amtpid) from
    (select m.groupid, m.benpkg, m.medtir, m.finyer,
    m.finper, sum(m.submed) as submed, sum(c.amtpid)
    from memhis m
    where groupid = '009944' and finyer = 2008
    group by m.groupid, m.benpkg, m.medtir, m.finyer, m.finper,
    (select sum(c.amtpid) as amtpid
    from clmhis c
    where m.groupid = c.groupid
    and trim(m.benpkg) = trim(c.prodid)
    group by c.groupid, c.prodid, to_char(c.datpid,'yyyy'),
    to_char(c.datpid,'mm')));

  2. #2
    Join Date
    Jul 2008
    Location
    Belgium
    Posts
    17
    Hello


    Maybe this will help you to find your results?

    select m.groupid, m.benpkg, m.medtir, m.finyer, m.finper, sum(m.submed) as sum_ submed,
    (select sum(c.amtpid)
    from clmhis c
    where m.groupid = c.groupid
    and trim(m.benpkg) = trim(c.prodid)
    group by c.groupid, c.prodid, to_char(c.datpid,'yyyy'), to_char(c.datpid,'mm')) as sum_amtpid
    from memhis m
    where groupid = '009944' and finyer = 2008
    group by m.groupid, m.benpkg, m.medtir, m.finyer, m.finper


    Greetings
    ld_be

  3. #3
    Join Date
    Aug 2008
    Posts
    2
    Thanks but that returns an error as well:
    select m.groupid, m.benpkg, m.medtir, m.finyer, m.finper, sum(m.submed) as sum_ submed,
    *
    ERROR at line 1:
    ORA-00923: FROM keyword not found where expected.

    I used to be able to do scripts like this but haven't done one in so long I just can't get it right!

  4. #4
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    You are referencing a table alias C which is not in FROM clause

    select groupid, benpkg,
    medtir, finyer, finper,sum(submed), sum(amtpid) from
    (select m.groupid, m.benpkg, m.medtir, m.finyer,
    m.finper, sum(m.submed) as submed, sum(c.amtpid)
    from memhis m
    where groupid = '009944' and finyer = 2008
    group by m.groupid, m.benpkg, m.medtir, m.finyer, m.finper,
    (select sum(c.amtpid) as amtpid
    from clmhis c
    where m.groupid = c.groupid
    and trim(m.benpkg) = trim(c.prodid)
    group by c.groupid, c.prodid, to_char(c.datpid,'yyyy'),
    to_char(c.datpid,'mm')));

  5. #5
    Join Date
    Jul 2008
    Location
    Belgium
    Posts
    17
    Quote Originally Posted by rjrichardson
    Thanks but that returns an error as well:
    select m.groupid, m.benpkg, m.medtir, m.finyer, m.finper, sum(m.submed) as sum_ submed,
    *
    ERROR at line 1:
    ORA-00923: FROM keyword not found where expected.

    I used to be able to do scripts like this but haven't done one in so long I just can't get it right!

    I see now that I placed a space and that was wrong.
    sum_ submed must be sum_submed

Posting Permissions

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