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
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 |
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 |
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 |
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 |
What is the use of stored procedures?
Is crud a cuss word?
What is correlated sub-query?
What is difference between joins and union?
How do I find duplicates in a single column in sql?
How to select the Nth maximum salary from Table Emp in Oracle SQL Plus ?
How do you remove duplicates without using distinct in sql?
What is the limitation on the block size of pl/sql?
Why are aggregate functions called so?
What do you understand by pl/sql packages?
what are date and time intervals? : Sql dba
Write a sql to print only character form the below string. @So&*CIE%$TE@GEN!@RAL
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)