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

how to start mysql server? : Sql dba

615


How to combine two stored procedures in sql?

595


Explain what is a subquery ?

656


What is embedded sql with example?

546


Can we use join in subquery?

567






What is the use of sql trace?

481


What is write ahead logging in sql server?

564


Explain aggregate functions are available there in sql?

534


How sql query is executed?

559


GLOBAL TEMPORARY TABLE over Views in advantages insolving mutating error?

2576


What is the difference between join and natural join?

475


Is nosql relational?

549


Is sql low level language?

579


How to know the last executed procedure?

591


Why is there a need for sqlcode and sqlerrm variables?

587