user_questions テーブル (UserQuestion モデル) と user_answers テーブル (UserAnswer モデル) があり、この形式のデータがあります。
              user_questions table:
+------+-----------------------------------------------------+---------------------+
| id   | question                                            | created_at          |
+------+-----------------------------------------------------+---------------------+
|  1 | Is question asker is a fool?              | 2011-03-12 03:23:44 |
| 2 | have we got an answer yet?                 | 2011-03-12 03:24:06 |
+------+-----------------------------------------------------+---------------------+
          user_answers table:
+------+-------+------------------+---------------------+
| id   | value | user_question_id | created_at          |
+------+-------+------------------+---------------------+
| 1 | Yes he is!    |             1 | 2011-03-12 04:23:44 |
| 2 | OC he is!  |             1 | 2011-03-12 05:23:44 |
| 3 | yup he is!  |             1 | 2011-03-12 05:23:44 |
+------+-------+------------------+---------------------+
ここで、質問の平均年齢を見つける必要があります。avg(user_question.created_at - min(user_answers.created_at))
上記のデータでは: user_question(1) は正確に 1 時間で最初の回答を得たため、彼の年齢は : 1 時間です。
user_question(2) はまだ回答を得ていないため、その年齢は (DateTime.now - user_question.created_at(1000 時間としましょう)) です。
結果出力 = (1 + 1000)/2
私は mysql の合計、平均、最小、最大の操作に精通しています。しかし、残念なことに、レール結合演算子を使用して最終的な解決策を得るために、ここで非常に苦労しています。