July 4, 2006 at 4:03 am
VERY URGENT...How to find employee having experience>250 months
July 4, 2006 at 4:15 am
You might find that you try members' patience if you repeatedly post the same question three times. If you post it in the correct place just once, we will still see it.
We need much more information than you're giving, as well. Post the table structure, some sample data and what you expect the result set to be and somebody will be able to help.
John
July 4, 2006 at 4:35 am
Using sysdate() function get the difference in the month
select * from employee where
datediff(month,sysdate(),person_starting_date)>250
July 5, 2006 at 1:50 am
Private message from original poster:
Table structure is like this..
empId,Name,Address,Salary,Hire Date,Department
Sample data:
001,Lenin,bangalore,30000,12 Sep 2004,HR
I think Avinash means to use getdate() instead of sysdate()... Also, if your table is large then you can put it like this to make it more likely that any index you have on the [Hire Date] column will be used by the query optimiser:
select [Name] from YourTable
where [Hire Date] < dateadd (month, -250, getdate())
John
July 5, 2006 at 12:51 pm
You may also use this:
Select * from TableName
Where datediff(month,HireDate,getdate())>250
Note: HireDate is the column name.
It should return same result.
July 6, 2006 at 7:35 am
Yes, but it will not utilize any indexes. John's query will.
N 56°04'39.16"
E 12°55'05.25"
July 8, 2006 at 11:05 am
I always wait on "Very Urgent" requests like this that have such a simple basis... it usually means that someone is taking an SQL test as part of an interview and, frankly, if they can't answer such simple questions, they don't deserve the job.... so, I wait...
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply