0 votes
in Oracle by

Find the error from the below SQL Query?

SELECT Name, YEAR(BirthDate) AS BirthYear
FROM StudentDetails
WHERE BirthYear >= 1998;

1 Answer

0 votes
by

Ans is 

This query will throw an error on the WHERE clause. Although an alias is specified in the SELECT clause it is not visible in the WHERE clause. The correct code can be written as follows:
SELECT Name, YEAR(BirthDate) AS BirthYear
FROM StudentDetails
WHERE YEAR(BirthDate) >= 1998;

...