Azu Posted October 31, 2007 Share Posted October 31, 2007 Hello.. can somebody please tell me why this is giving me a syntax error and how to fix it? select * from table group by row order by count(group(row)) Link to comment https://forums.phpfreaks.com/topic/75486-solved-syntax-error/ Share on other sites More sharing options...
trq Posted October 31, 2007 Share Posted October 31, 2007 Because it is syntactly incorrect. COUNT returns a number, do you have a filed named with that number? Link to comment https://forums.phpfreaks.com/topic/75486-solved-syntax-error/#findComment-381851 Share on other sites More sharing options...
Azu Posted October 31, 2007 Author Share Posted October 31, 2007 Okay I have a table like this ID UserID Stuff 1 3 Blah 2 5 Blah 3 1 Blah 4 3 Blah 5 9 Blah 6 20 Blah 7 3 Blah 8 15 Blah 9 5 Blah etc And I want the query to return this 3,3 5,2 (the rest),1 But I can't get it to work :s Link to comment https://forums.phpfreaks.com/topic/75486-solved-syntax-error/#findComment-381867 Share on other sites More sharing options...
svivian Posted October 31, 2007 Share Posted October 31, 2007 I think you just need count(row) rather than count(group(row)) but I'm not sure. Can you explain in more detail how you want that output (3,3 / 5,2), where you're getting those number from? Do you want to obtain the number of times each UserID is used? Link to comment https://forums.phpfreaks.com/topic/75486-solved-syntax-error/#findComment-381878 Share on other sites More sharing options...
fenway Posted October 31, 2007 Share Posted October 31, 2007 Sounds like you want: SELECT UserID, COUNT(ID) FROM yourTable GROUP BY UserID Link to comment https://forums.phpfreaks.com/topic/75486-solved-syntax-error/#findComment-381886 Share on other sites More sharing options...
Azu Posted October 31, 2007 Author Share Posted October 31, 2007 Thanks guys! ^^ Link to comment https://forums.phpfreaks.com/topic/75486-solved-syntax-error/#findComment-381947 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.