Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Rdb > Help with an SQ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 105 of 183
Post > Topic >>

Help with an SQL Query

by "Mike B" <mrcics2000-news-nomail@[EMAIL PROTECTED] > Apr 28, 2005 at 11:45 AM

I apologize if this is off-topic. If it is off-topic, please direct me to a

more appropriate group.

I am writing an SQL query for a project and am a little stuck. I need to 
classify a list of employees into age brackets. (E.g.. 16-15, 25-35, etc.)
I 
am using the Micro Focus NetExpress SQL Wizard in DB2 compatibility mode.

I created a table AgeBrackets

Range | Lower | Upper
-----------------------
16-25| 16        |25
25-35|25         |35

Then I created a view:

CREATE VIEW vAgeRange (
                   Range,
                   Start,
                   Last)
As
    SELECT      A1.RangeDesc,
                          Start_Date = Today - A1.RangeLow years + 1 days,
                         End_Date = Today - A1.RangeHigh years
     FROM         ALAMEDA.ALAMEDA.AGERANGE A1

To put the age brackets in dates starting from today, so I get the
earliest 
and latest date someone can be born to be in an age bracket.

I am now trying to create a view where for each row in my EMPLOYEE table,
I 
want to compare the Employee_DateOfBirth to the Start_Date, end_Date and
if 
it is BETWEEN those dates, I want to insert the RangeDesc into the new
view.

This is what I tried:

SELECT      E1.EMPLOYEE, E1.DoB, V1.Range
FROM         ALAMEDA.ALAMEDA.EMPLOYEE E1,
                   ALAMEDA.ALAMEDA.VAGERANGE V1
WHERE       (E1.DOB BETWEEN V1.Start AND V1.Last)

But this returns an empty Query.

I'm a little stuck and any pointers will be really helpful.

thanks
Mike

-- 
Mike B
 




 2 Posts in Topic:
Help with an SQL Query
"Mike B" <mr  2005-04-28 11:45:46 
Re: Help with an SQL Query
"Bob M. Lee" &l  2005-05-06 21:39:26 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Sat Jul 5 23:52:32 CDT 2008.