Count and order by - error

S

SpookiePower

I'm trying to count how many time
each user have been logged in to my website
and then sort them desc. But I keep getting
an error.

SELECT user, count(user) AS logins
FROM tsigninlog
GROUP BY user
order by logins desc;

This SQL shows a form where I must enter a parameter value.
Why does it not works ?
 
J

Jason Lepack

There is no field called logins. logins doesn't exist until after the
query is executed. Therefore your order by column should be
count(user).

Cheers,
Jason Lepack
 
S

SpookiePower

Jason said:
There is no field called logins. logins doesn't exist until after the
query is executed. Therefore your order by column should be
count(user).

Cheers,
Jason Lepack

Thanks. It works now :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top