April 27, 2006 at 10:02 am
For a set of products I have prices broken down by age.
Product 1
5 - 15 = $20
16 - 60 = $18
65 - 255 = $17
Product 2
...etc
If I have a table containing various persons ages
then every persons age must occur in a products age range in order for a product to be selected.
I know there must be a simple set based solution but I'm totally decaffed. Can anyone help
April 27, 2006 at 10:18 am
What are the table structures?
Show us an expected result set.
April 27, 2006 at 11:19 am
I'm assuming that you have a table for people and a table for products... You might want to think about doing your join something like this (pseudocode, as above the actual table definition might be helpful):
FROM people pep
JOIN product prod
ON pep.age BETWEEN prod.age_low AND prod.age_high
This assumes a lot about how your db is designed however...
April 27, 2006 at 1:25 pm
After a stiff expresso I sorted it.
Table structure was loosely
Ages were produced by a table function returning a single column of ages.
What I wanted was to bring back all products that could satisfy all ages.
In my earlier example, if I had an age of 4 in the list of ages then no records for products that did not have an age band that included 4 would be returned.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply