Thanks! I was conforted to see that you didn't find it THAT easy!!

Le 4 avril 2012 18:36, CRPence <CRPbottle@xxxxxxxxx> a écrit :

On 04-Apr-2012 07:19 , Dave wrote:
<<SNIP>> I was trying to actually show the results in
the same format as the original table, ie, like this :

client, child's date of birth

The original reply from Paul [under the original "Subject: Sql
muddle"] gave the most direct answer with that effect, albeit written
with two names for the client column and having used an "AGE" column
versus a "DOB" (Date Of Birth) column. Rewritten, it would look like:

SELECT *
FROM theTABLE orig
WHERE EXISTS ( SELECT '1' /* client has a child > 20 years */
FROM theTABLE gt20
WHERE orig.CLIENT = gt20.CLIENT
AND year(current date - gt20.DOB) > 20 )
AND EXISTS ( SELECT '1' /* client has a child < 20 years */
FROM theTABLE lt20
WHERE orig.CLIENT = lt20.CLIENT
AND year(current date - lt20.DOB) < 20 )

so, extracting each row that satisfied the search criteria.

Hmm... that muddles as well. Should the query return all client rows
for which exists at least one child over 20 and at least one child under
20, or only return the rows of those same clients but for which the
child's age is not equal to 20? If the latter, then add another ANDed
predicate: AND year(current date - orig.DOB) <> 20

Regards, Chuck
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.




This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].