On Wed, Jan 25, 2012 at 3:30 PM, rohit <[email protected]> wrote: > On Jan 25, 7:18 am, Christian MICHON <[email protected]> > wrote: >> Hi, >> >> I sometimes have to perform the following in my H2 databases: >> >> SELECT COUNT(MYKEY),MYKEY FROM MYTABLE GROUP BY MYKEY HAVING >> COUNT(MYKEY) > 1 ORDER BY COUNT(MYKEY) DESC >> >> Is there a way to make it more sequel-ish ? I would rather have a more >> generic approach, since I'm not always connecting to H2 databases. >> >> This is the first time I have a more complex use of sql count(), but >> apparently count in pure sequel does not take any argument. >> >> Thanks in advance for any pointer you could share. >> >> -- >> Christian > > DB[:mytable]. > select{[count(:mykey).as(:mycount), :mykey]}. > group(:mykey). > having{count(:mykey) > 1}. > order(:mycount.desc) >
Nice! Works perfectly. Thanks Rohit -- Christian -- 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.
