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 / sdp

select * from emp
where trunc(months_between(sysdate, hiredate))=2;

Is This Answer Correct ?    34 Yes 10 No

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

Answer / suneel

select * from af where months_between(sysdate,hiredate)<=2

Is This Answer Correct ?    15 Yes 2 No

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

Answer / raji_4u

select *
from emp
where hiredate
between add_months(trunc(sysdate,'Month'),-2)
and trunc(sysdate,'Month')-1

This works for sure. 100 %

Is This Answer Correct ?    14 Yes 1 No




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

Answer / avi007

select * from employee where (sysdate-hiredate) <=60

Is This Answer Correct ?    6 Yes 2 No

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

Answer / venkat

select *from emp where floor(months_between
(sysdate,hiredate))=2;

Is This Answer Correct ?    6 Yes 5 No

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

Answer / arijit

take Mon(like sep,oct,mar etc)
and year( like 2006,2007,1980 etc) as input...
and execute this query..

select empno,ename,hiredate from emp1
where hiredate between
add_months(to_date('01-'|| upper('&Mon')||'-'||&yr,'DD-MON-
YYYY'),-2) and last_day(add_months(to_date('01-'|| upper
('&Mon')||'-'||&yr,'DD-MON-YYYY'),-1))

Is This Answer Correct ?    2 Yes 1 No

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

Answer / kesava

100% sure execute

select * from emp
where hiredate between
trunc(add_months(last_day(sysdate),-3)+1) and
trunc(add_months(last_day(sysdate),-1))

Is This Answer Correct ?    1 Yes 0 No

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

Answer / balaji s.t

select convert(varchar(10),
dateadd(dd,-(day(dateadd(mm,1,getdate()))-1), dateadd(mm,-2,getdate())), 120),

convert(varchar(10),dateadd(dd,-(day(getdate())),getdate()),120)

Is This Answer Correct ?    1 Yes 1 No

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

Answer / satish

select * from emp where
round(months_between(sysdate,hire_date) in(1,2);

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 / 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

Post New Answer



More SQL PLSQL Interview Questions

What steps server process has to take to execute an update statement?

0 Answers  


How many postgresql users are there, worldwide?

0 Answers  


Which command is used to delete a trigger?

0 Answers  


What is user defined functions?

0 Answers  


What is hibernate and its relation to sql?

0 Answers  






What are different methods to trace the pl/sql code?

0 Answers  


What are the pre requisites?

1 Answers  


what will be the output: select 1 from emp union all select 2 from emp;

2 Answers   iNautix,


What is auto increment?

0 Answers  


What do you know by pl/sql cursors?

0 Answers  


What is the use of function "module procedure" in pl/sql?

0 Answers  


What has stored procedures in sql and how we can use it?

0 Answers  






Categories