Home » SQL & PL/SQL » SQL & PL/SQL » Views
Views [message #10886] Sun, 22 February 2004 12:40 Go to next message
LT
Messages: 29
Registered: August 2003
Junior Member
Hi All

I have a requirement to create a view that will be used to run a report in MSAccess. The purpose of creating the view is to speed up the report creation.

However, there is a field that I would like to have in my view that I would like to calculate based on a date of birth value.

Example - There is a 'Date of Birth' column in the view and I would like to calculate the time of life based on the date of birth and put it in my view. So say 'If less than 18 - Child else adult'.

I originally just put the DOB column in the view and told the users to use an expression in Access to calculate this but it is causing the report to take a long time to run.

Is there anyway I can calculate this automatically in my view during creation? Or does anyone else have any other ideas on how I could do this?

Regards.
Re: Views [message #10889 is a reply to message #10886] Sun, 22 February 2004 19:53 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9088
Registered: November 2002
Location: California, USA
Senior Member
SELECT DECODE (SIGN (18 - (MONTHS_BETWEEN (SYSDATE, dob) / 12)),
1, 'Child', 'Adult') AS child_or_adult
FROM your_table;
Re: Views [message #10900 is a reply to message #10886] Mon, 23 February 2004 03:51 Go to previous message
Shalini singh
Messages: 11
Registered: September 2002
Junior Member
select (case
when DOB < '18' then 'child'
else 'Adult' end ) time_of_life
from T_age;

In above sql, u can use T_age the table name from which u have to slect the age. and can put as a column in the created view
Previous Topic: MERGE stmt
Next Topic: Currency symbol,comma
Goto Forum:
  


Current Time: Fri Apr 19 07:39:06 CDT 2024