*select count(*) from ( * * SELECT loyalty_id FROM transactions GROUP BY loyalty_id HAVING COUNT(*)>1 * *) as t * problem when writing the corresponding rails queries...? I am using * Rails2.3.11* Also this have error *select sum(points) from transactions where transaction_type ="new_customer" or transaction_type= "review" or transaction_type= "purchase" . * * * *I tried like this Transaction.find(:id => :conditions =>["transaction_type = ? OR transaction_type = ? OR transaction_type = ?", ctype, ctype1,ctype2]).sum("points"). but it shows some ID error* * * *Thnk you* *vishnu* -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/pcWTdVnyRQ0J. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, Dec 13, 2011 at 8:31 PM, amvis <vgrkrishnan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> *select count(*) > from ( > * > * SELECT loyalty_id FROM transactions > GROUP BY loyalty_id > HAVING COUNT(*)>1 > * > *) as t > * > > problem when writing the corresponding rails queries...? I am using * > Rails2.3.11* > > Also this have error *select sum(points) from transactions where > transaction_type ="new_customer" or transaction_type= "review" or > transaction_type= "purchase" . * > * > * > *I tried like this Transaction.find(:id => :conditions > =>["transaction_type = ? OR transaction_type = ? OR transaction_type = ?", > ctype, ctype1,ctype2]).sum("points"). but it shows some ID error* >that some id error refers to the :*id =>* part. remove that and it should work ** Transaction.find(:conditions =>["transaction_type = ? OR transaction_type ? OR transaction_type = ?", ctype, ctype1,ctype2]) *> * > *Thnk you* > *vishnu* > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/pcWTdVnyRQ0J. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks for the reply.. sorry, that made a mistake when i post here. that query had''t an id. i think the problem with rails version..? am using rails2.3.11. This is mysql query *select sum(points) from transactions where transaction_type ="new_customer" or transaction_type= "review" or transaction_type= "purchase"* * * and also have one sub query to convert into active record * * *select count(*) from ( * * SELECT loyalty_id FROM transactions GROUP BY loyalty_id HAVING COUNT(*)>1 * *) as t * * * -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/MvkkV0K6C5IJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, Dec 13, 2011 at 9:00 PM, amvis <vgrkrishnan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks for the reply.. > > sorry, that made a mistake when i post here. that query had''t an id. i > think the problem with rails version..? am using rails2.3.11. > > This is mysql query *select sum(points) from transactions where > transaction_type ="new_customer" or transaction_type= "review" or > transaction_type= "purchase"* > * > * > and also have one sub query to convert into active record > * > * > *select count(*) > from ( > * > * SELECT loyalty_id FROM transactions > GROUP BY loyalty_id > HAVING COUNT(*)>1 > * > *) as t > * > * > * >can you post the error and the code that causes it?> ** > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/MvkkV0K6C5IJ. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.