0

I am trying to run this in Oracle SQL and it doesn't like it....

select seg.*,segp.order_num
from
    (select order_number,segment_id,copy_date,completion_date,number
    from LIB.V_SEGMENT
    where COMPLETION_DATE = TO_TIMESTAMP('2017-10-01', 'YYYY-MM-DD')
    ) as seg
inner join 
    (select segment_id,order_number,pcms_product_code
    from LIB.V_SEGMENT_PRODUCT
    where P_CODE in ('ABCD','DEFG')
    ) as segp on seg.order_number=segp.order_number and seg.segment_id=segp.segment_id;

It ended with 'SQL Command Not properly Ended'

Any tips?

Paul Abbott
  • 7,065
  • 3
  • 27
  • 45
Albert S
  • 177
  • 1
  • 3
  • 8
  • Remove the `AS` keyword in front of subquery aliases (`seg` and `segp`) - it may be allowed in other SQL dialects, but it is not permitted in Oracle. (It can be used, optionally, before **column** aliases, but not before table/subquery aliases.) –  Jan 25 '18 at 00:21
  • thanks @mathguy it works now after deleting the alias – Albert S Jan 25 '18 at 00:30
  • Getting good at Google searches will help you a lot in the long run. You can search for the phrase "SQL command not properly ended" - you will find several different "mistakes" that can lead to this error message, and you would quickly recognize that in your case it's the `as` keyword in front of subquery aliases. Happy coding! –  Jan 25 '18 at 00:32

0 Answers0