![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
This is greatly simplified, but I have a database that contains the following fields and sample data: First,Last,Address,Gender,Age John,Doe,123 Main,M,34 Jane,Doe,123 Main,F,32 Jacob,Doe,123 Main,M,15 Bob,Smith,234 Main,M,45 Tom,Smith,234 Main,M,43 Sara,Brown,345 Main,F,34 Nancy,Brown,345 Main,F,37 Don,Black,456 Main,M,34 Sally,Black,456 Main,F,30 I need to come up with a query that will return "married households" using the criteria that there is a man and women listed at the same address both over the age of 18 years old. The query needs to list everyone at the household if the household meets the criteria (not just the two married people) As applied to the above data it should return these records: John,Doe,123 Main,M,34 Jane,Doe,123 Main,F,32 Jacob,Doe,123 Main,M,15 Don,Black,456 Main,M,34 Sally,Black,456 Main,F,30 I imagine I have to use a subquery to accomplish this but I am looking for some assistance getting a general method to work correctly. In my actual application, there are additional fields such as City, State, Zip and a lot of other information columns. I hope I can come up with SQL that is flexible enough to be expanded to the full application. Also, I didn't include a primary key in the data listed above so feel free to include an ID field in any proposed solution. Thanks in advance. |
#3
| |||
| |||
|
|
I need to come up with a query that will return "married households" using the criteria that there is a man and women listed at the same address both over the age of 18 years old. The query needs to list everyone at the household if the household meets the criteria (not just the two married people) |
#4
| |||
| |||
|
|
dandiebolt (AT) gmail (DOT) com wrote: I need to come up with a query that will return "married households" using the criteria that there is a man and women listed at the same address both over the age of 18 years old. The query needs to list everyone at the household if the household meets the criteria (not just the two married people) Wow, I hope that's a for-instance, and not an actual algorithm. |
![]() |
| Thread Tools | |
| Display Modes | |
| |