The following code below works as a Postgre query, i'm trying to call it inside my rails app and assigning it to an object: @agent_monthly_performance.
SELECT user_id AS user_id,
to_char(created_at,'Mon-YY') AS year_month,
sum(total_amount) AS amount,
sum(total_lm) AS lm
FROM agent_sales
WHERE created_at > NOW() - INTERVAL '1 year'
GROUP BY user_id, year_month"
Once that works, will I be able to call it via @agent_monthly_performance.year_month? I'm aware that i've created new columns that aren't in my schema via "AS" command. (ex. year_month).