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.

Answer Posted / 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 ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is serial sql?

503


What is the cause of mutating table error and how can we solve it?

576


What is cross join example?

527


Is sql considered coding?

538


what tools available for managing mysql server? : Sql dba

508






What is cursor explain with example?

526


What is the difference between rollback and rollback to statements?

560


how to check myisam tables for errors? : Sql dba

559


How do I truncate a word?

502


What is procedure explain with example?

511


Is time a data type in sql?

458


Give the order of sql select?

585


How to disable a trigger name update_salary?

645


What is the usage of nvl function?

565


tell us something about heap tables. : Sql dba

568