- It's not very common that the same mother has had two children (not twins)
within 12 months. Besides, only during a limited timeframe the ages in years
of two such children would be the same.

It is possible, and actually is not that uncommon where I live (Utah) - my wife and I have a few friends that have done it.


- Boris and Vladimir are mathematicians. If they start using ages as a whole
number of years than it is likely that they forget the real concept of age
and just use integer numbers instead.

I was wondering for a second if the use of irrational numbers for ages was permitted :-) But it is good to simplify. If we were not willing to, math in general would end up being completely useless.


- If "eldest" cannot be used anymore, one needs to know how many windows the
building has...

A more on-topic issue:
How can one list the ages sorted and thus use a DISTINCT to filter
permutations?
How can one query "there is an eldest"?

Very ugly - I'm glad Boris and Vladimir are mathematicians :-)


mysql> SELECT a1.age1,b1.age1,c1.age1 , a.age1 + b.age1 + c.age1 as sumage, a1.age1 + b1.age1 + c1.age1 as sumage1 FROM age1 a,age1 b, age1 c, age1 a1, age1 b1, age1 c1 WHERE a.age1 * b.age1 * c.age1 =36 and a.age1 >= b.age1 and b.age1 >= c.age1 and a1.age1 > b1.age1 and b1.age1 >= c1.age1 and a1.age1*b1.age1*c1.age1 = 36 and (a1.age1 != a.age1 or b1.age1 != b.age1 or c1.age1 != c.age1) HAVING sumage = sumage1 ORDER BY sumage ;
+------+------+------+--------+---------+
| age1 | age1 | age1 | sumage | sumage1 |
+------+------+------+--------+---------+
| 9 | 2 | 2 | 13 | 13 |
+------+------+------+--------+---------+
1 row in set (0.03 sec)


And look at the explain:

mysql> explain SELECT a1.age1,b1.age1,c1.age1 , a.age1 + b.age1 + c.age1 as sumage, a1.age1 + b1.age1 + c1.age1 as sumage1 FROM age1 a,age1 b, age1 c, age1 a1, age1 b1, age1 c1 WHERE a.age1 * b.age1 * c.age1 =36 and a.age1 >= b.age1 and b.age1 >= c.age1 and a1.age1 > b1.age1 and b1.age1 >= c1.age1 and a1.age1*b1.age1*c1.age1 = 36 and (a1.age1 != a.age1 or b1.age1 != b.age1 or c1.age1 != c.age1) HAVING sumage = sumage1 ORDER BY sumage ;
+-------+-------+---------------+---------+---------+------+------+----------------------------------------------+
| table | type | possible_keys | key | key_len | ref | rows | Extra |
+-------+-------+---------------+---------+---------+------+------+----------------------------------------------+
| a | index | PRIMARY | PRIMARY | 1 | NULL | 20 | Using index; Using temporary; Using filesort |
| b | ALL | PRIMARY | NULL | NULL | NULL | 20 | Range checked for each record (index map: 1) |
| c | ALL | PRIMARY | NULL | NULL | NULL | 20 | Range checked for each record (index map: 1) |
| a1 | index | PRIMARY | PRIMARY | 1 | NULL | 20 | Using index |
| b1 | ALL | PRIMARY | NULL | NULL | NULL | 20 | Range checked for each record (index map: 1) |
| c1 | ALL | PRIMARY | NULL | NULL | NULL | 20 | Range checked for each record (index map: 1) |
+-------+-------+---------------+---------+---------+------+------+----------------------------------------------+



This is a good example of a problem that *could* be solved with SQL, but *should not* be, at least if the solution is to be executed repeatedly.


--
Sasha Pachev
Create online surveys at http://www.surveyz.com/

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to