Reputation: 1
select hr_emp_id
from hr_holidays_requests
where (select DATEPART(YEAR, hr_to_date) from hr_holidays_requests) >
any (select DATEPART(YEAR,hr_from_date) as stasrt from hr_holidays_requests)
error
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Upvotes: 0
Views: 43
Reputation: 99
You should try this for comparing two colunm values . SELECT hr_emp_id FROM hr_holidays_requests WHERE DATEPART(YEAR, hr_to_date) > DATEPART(YEAR, hr_from_date);
Upvotes: 0
Reputation: 171
Correct my if I am wrong
Do you want to select all items from hr_holidays_requests where hr_to_date is geater than hr_from_date compared by the year? Maybe you are thinking a little bit too complex, hope I got correctly
SELECT hr_emp_id FROM hr_holidays_requests
WHERE DATEPART(YEAR, hr_to_date) > DATEPART(YEAR,hr_from_date);
Upvotes: 1