Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Sickboy
Starting Member
1 Post |
Posted - 2003-03-11 : 10:11:35
|
| I have calculated the age of a person and rounded it but want to say if they are older than 65 and place a Y for yes or a N for No if they are tried this but keep gettign errormethod 1DECODE(ROUND((F.TODAYS_DATE - C.DATE_OF_BIRTH) / 365) AS "AGE"method 2Decode(Sign(65-ROUND((F.TODAYS_DATE - C.DATE_OF_BIRTH) / 365)), 1, N, Y )how can I do it |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2003-03-11 : 10:17:32
|
| If you're using SQL Server, there is no DECODE function. If you're using Oracle, you'll need to post your question on an Oracle forum, we specialize in SQL Server here on SQL Team.From what I know of Oracle, this version should give what you want:Decode(Sign(65-ROUND((F.TODAYS_DATE - C.DATE_OF_BIRTH) / 365)), 1, 'N', 'Y' )You probably got an error because it was treating Y and N as column names instead of strings. |
 |
|
|
Peter Dutch
Posting Yak Master
127 Posts |
Posted - 2003-03-11 : 10:17:47
|
| This is Oracle? (since you use DECODE)I think you need a CASE WHEN |
 |
|
|
|
|
|