Topic: why alias names for columns not displaying in results

Hi friends

  I have written query as
  Model.find(:all ,:select => 'user_id, count('login') as  count_login',:group => 'user_id')

this returning only user_id

if i am giving aliasname is columns then it returning count value

i.e Model.find(:all ,:select => 'user_id, count('login') as  login',:group => 'user_id')

why it's happening.How to set aliasnames

Re: why alias names for columns not displaying in results

Someone will probably have a better answer for you, but I got it to work in a find_by_sql and how I am doing it is:

User.find_by_sql(["select u.id, count(u.login) as 'login' from users u group by u.id"])

If your model is users.