Andrius Chamentauskas wrote:
> Just do SalesFact.first(:include =>
> [:on_market_date_dimension, :sale_date_dimension]). Then you can
> access dates with sales_fact.on_market_date_dimension and
> sales_fact.sale_date_dimension.

Ah - yes, that would work!  But am I wrong in thinking that pushes all 
the logic out of the DB and into Rails?  For example, consider the 
following query that shows only sales that closed in Q1:

SELECT sale.asking_price, sale.sale_price, listed.datetime AS 
listed_date, sold.datetime AS sold_date
FROM sales_facts sale
JOIN date_dimensions listed ON listed.id = 
sale.on_market_date_dimension_id
JOIN date_dimensions sold ON sold.id = sale.sale_date_dimension_id AND 
sold.quarter = "Q1";

If I do an :include, I'm not sure how to keep the sold.quarter = "Q1" 
within SQL.  I'm probably missing something...

P.S.: I've re-framed this question in 
http://www.ruby-forum.com/topic/205883 -- perhaps it's clearer there?
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to