On Jul 8, 1:11 pm, Eric <[email protected]> wrote: > > 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"}>]
That's certainly odd. You are using the exact same query that Sequel is sending the database, and getting fewer results? If so, could you put together a self contained example that shows the problem? If you aren't using the exact same query, there may be a reason SQLite is returning different results. In that case post the SQL that gives correct results, and I should be able to show you the Sequel equivalent. Jeremy --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
