1

I'm new to SQL and I'm currently writing a query and I got this error. Any help will be appreciated.

ORA-00933: SQL command not properly ended 

My Query below:

CREATE VIEW moscow_paris_overlap(SSN) AS 
    SELECT t1.SSN 
    FROM assign AS T1 
    INNER JOIN assign AS T2 
    ON T1.SSN = T2.SSN 
    WHERE T1.EndYear = T2.StartYear 
    AND T1.CityName = 'Moscow' 
    AND T2.CityName = 'Paris';

    SELECT DISTINCT emp.* FROM emp INNER JOIN moscow_paris_overlap ON emp.SSN = moscow_paris_overlap.SSN;
0

1 Answer 1

2

First, you need to separate the CREATE VIEW from the query which uses it. If you're using SQL*Plus or something similar you can do this by putting a / on a separate line between the two. This will cause the CREATE VIEW to be executed first.

Second, AS can't be used in a FROM or INNER JOIN when defining a table alias. Change the FROM clause in your view creation to FROM ASSIGN T1. Similarly, the INNER JOIN should be INNER JOIN ASSIGN T2.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.