select sum(min_salary), sum(max_salary) from jobs; これをActiveRecordで書きたい。 ベタに書くと rec = Job.select(<<-SELECT).all[0] SUM(MIN_SALARY) AS MIN_SALARY ,SUM(MAX_SALARY) AS MAX_SALARY SELECT # => SELECT SUM(MIN_SALARY) AS MIN_SALARY # ,SUM(MAX_SALARY) AS MAX_SALARY # FROM "JOBS" p rec.min_salary # => 124888 p rec.max_salary # => 251088 こうなる。 関係ないけど、仕事中にActiveRecordの書き方で詰まったら、諦めて直接SQL書いた方が早いよね。閑話休題。 こう書けそう