jQuery in Action, 2nd edition*
The moose likes JDBC and the fly likes How to find out number of years worked using sql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to find out number of years worked using sql " Watch "How to find out number of years worked using sql " New topic
Author

How to find out number of years worked using sql

Pol Appan
Ranch Hand

Joined: Aug 26, 2004
Posts: 144
Hello,


How to find from a table which has hiredate and should return number of years worked with range like 0-5, 5-10,10-15 etc.

Any help is highly appreciated.

Thanks


Never take anything for granted because you never know when you will lose it
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

What database are you using? Date functions are often db-specific, so we'd need to know that.


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

Are you trying to do it in a single SQL statement or in PLSQL such as in a stored procedure? Also is the range part of the input parameters? Such as if I set 7 it should do 0-7, 7-14, etc instead of increments of 5?


My Blog: Down Home Country Coding with Scott Selikoff
Pol Appan
Ranch Hand

Joined: Aug 26, 2004
Posts: 144
I am using Oracle 9i and not using pl/sql, plain sql.

Thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to find out number of years worked using sql