Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need elegant SQL for Dueling Ranges Ages and FY
Message
From
26/02/2003 11:15:19
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00758122
Message ID:
00758146
Views:
17
This message has been marked as a message which has helped to the initial question of the thread.
>Hi...I'm tearing my hair out trying to get an elegant SQL query for finding:
>
>People who were 16 - 21 years of age,
>during our Fiscal Year 2001 (which is 07/1/2000 - 06/30/2001)
>
>I'm using bdate BETWEEN CTOD('07/01/1985') AND CTOD('06/30/1986'),
>and subqueries,
>etc...
>
>But what I want is something like:
>
>SELECT names;
>
>--stuff goes here--
>
>AND age between 16 and 21
>
>TIA

ldFiscalYearStart = {^2000/07/01}
ldFiscalYearEnd = {^2001/06/30}
lnMinAge = 16
lnMaxAge = 21

ldMinBdate = GOMONTH(ldFiscalYearStart,-12*lnMaxAge)
ldMaxBDate = GOMONTH(ldFiscalYearEnd,-12*lnMinAge)

where bdate between ldMinBDate and ldMaxBdate

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform