Count unique records with DataMapper
Saturday 01/3/2009 – Category: Uncategorized
dm-aggregates provides an aggregate method that allows for "multiple aggregate functions to be used in a single query, with automatic grouping when :fields is specified"
Hit.aggregate(:ip_address).length
Will yield the number of unique IP addresses in the hits table.
Leave a Reply
Recent Posts
- Flickr Original updates
(Saturday 08/7/2010 – 7 Comments) - LED Light for iPhone 4
(Monday 06/28/2010 – 48 Comments) - WWDC 2010: Worth Every Minute
(Monday 06/14/2010 – No Comments) - Flickr Original for Safari 5!
(Wednesday 06/9/2010 – 26 Comments)
