> This should give you roughly the same SQL:
>
> DB[:tbl].select{TO_CHAR(created, 'YYYY-MM').as(month)}.distinct.order
> (1).all
>
> Jeremy
This would work if I was hitting an Oracle instance, but Sqlite
doesn't have TO_CHAR capability. The query would be
SELECT DISTINCT
STRFTIME ( '%Y-%m', created ) AS month
FROM
tbl
ORDER BY
1 ASC;
which I guess would be become
DB[:tbl].select{ strftime( '%Y-%m', call_dt ).as( month ) }.
distinct.order( :call_dt ).all
# sql=> SELECT DISTINCT strftime('%Y-%m', call_dt) AS 'month' FROM
calls ORDER BY call_dt
Which if I run in sqlite I get two rows (2009-06 & 2009-07). Yet when
I run it in my code, I get just one value:
m: [#<Call @values={:month=>"2009-07"}>]
Eric
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sequel-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/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---