How do I do the following in Rails 3?
CREATE TEMPORARY TABLE average_user_total_time
(SELECT SUM(time) AS time_taken
FROM scores
WHERE created_at >= '2010-10-10'
and created_at <= '2010-11-11'
GROUP BY user_id);
SELECT COUNT(*) from average_user_total_time WHERE time_taken > 60 and time_taken < 600
I have tried to do something like
create_table (:average_user_total_time), :temporary=> true do |t|
end
but not sure how to use it exactly. I need to use it within my app and not in a migration.