I want to display the employees who have joined in last two
months. (It should be executed randomly means If I execute
the query in March it should display Jan and Feb joined
employees. Same query if i execute in Feb, 2007 it should
display dec, 2006 and jan 2007 joined employees.

Answers were Sorted based on User's Feedback



I want to display the employees who have joined in last two months. (It should be executed randomly..

Answer / pracheth

select * from temployees where to_char(hiredate,
'month') in
(to_char(trunc(sysdate,'month')-30,'month'),to_char(trunc(sysdate,'month')-60,'month'))

Is This Answer Correct ?    0 Yes 1 No

I want to display the employees who have joined in last two months. (It should be executed randomly..

Answer / venu

select * FROM(SELECT ENAME, Abs(to_date('&DATE' ,'dd/mm/yy')- HIREDATE) AS DATES FRom EMP) where dates<60;

Is This Answer Correct ?    0 Yes 1 No

I want to display the employees who have joined in last two months. (It should be executed randomly..

Answer / subbu

Assuming that the Table name is "Employee" & his/her date of
joining is stored in column "JoiningDate". Below query gives
you the result


If (Month(GetDate()))=1
Select * from Employee Where (Month(JoiningDate)) in (11,12)
And Year(JoiningDate)=Year(GetDate()-1)
Else if Month(GetDate())=2
Select * from Employee Where (Month(JoiningDate)=12 And
Year(JoiningDate)=Year(GetDate()-1)) or
(Month(JoiningDate)=1 And Year(JoiningDate)=Year(GetDate()))
Else
Select * from Employee Where
Year(JoiningDate)=Year(GetDate())And
Month(JoiningDate)>=Month(GetDate()-2) And
Month(JoiningDate)<=Month(GetDate()-1)

Is This Answer Correct ?    0 Yes 4 No

I want to display the employees who have joined in last two months. (It should be executed randomly..

Answer / xyz

select * from emp where add_months(sysdate ,-2);

Is This Answer Correct ?    1 Yes 9 No

I want to display the employees who have joined in last two months. (It should be executed randomly..

Answer / test

Join_date is the column in Emp table.

select * from emp
where join_date between sysdate and sysdate - 60

Is This Answer Correct ?    2 Yes 11 No

Post New Answer

More SQL PLSQL Interview Questions

Does sql full backup truncate logs?

0 Answers  


How many rows can sqlite handle?

0 Answers  


What is use of trigger?

0 Answers  


What is a sql driver?

0 Answers  


define sql update statement ? : Sql dba

0 Answers  






What is row_number () in sql?

0 Answers  


Why having clause is used in sql?

0 Answers  


What does the acronym acid stand for in database management?

0 Answers  


What is a procedure in pl sql?

0 Answers  


What is meant by <> in sql?

0 Answers  


List out the acid properties and explain?

0 Answers  


what are all different types of collation sensitivity? : Sql dba

0 Answers  


Categories