Table: CREATE TABLE `age1` ( `age1` tinyint(2) NOT NULL auto_increment, PRIMARY KEY (`age1`) ) TYPE=MyISAM AUTO_INCREMENT=21 ;
Data: INSERT INTO `age1` VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11), (12), (13), (14), (15), (16), (17), (18), (19), (20); Query: SELECT * , a.age1 + b.age1 + c.age1 as sumage FROM `age1` a JOIN `age1` b JOIN `age1` c WHERE a.age1 * b.age1 * c.age1 =36 ORDER BY sumage We now have to search for combinations that - have more than one unique set of sorted ages for a certain sum (since Boris didn't know the ages while he knew the sum) - have only one highest age (since there is an "eldest") Looking at the output this would only be true for ages 9, 2 and 2 Regards, Jigal. ----- Original Message ----- From: "Tom Roos" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, March 08, 2004 9:31 AM Subject: SQ puzzle SQL puzzle from the Informix mailing list: Two mathematicians (Boris and Vladimir) met accidently for the first time in 20 years. They greet each other and begin catching up on their respective lives. Boris asks Vladi "Do you have any children?" "Yes" replies Vladimir, "I have three." "How old are they?", asks Boris. "The product of their ages is 36 and the sum of their ages is equal to the number of windows on that building across the street." Boris looks at the building, counts the windows then says "Vladi, that still doesn't tell me the ages." "Ah, says Vladi, then I must tell you that the eldest has red hair." "Oh", says Boris, "now I know their ages." What are the ages of Boris' children? Create a table, load it with data, and write a single SQL statement to produce the data set required to deduce the answer. Of course the problem cannot be solved with M$ SQLServer :-) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]