Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
I'm not sure you have understood what group by does, or maybe I haven't understood your question...
"Group by" is an aggregate function, that will group all similar values as one.
Often, you use it with an "using" statement, which allows, for example, to count how many time a certain value is present and to display only those who are present multiple times
Code:
select count(username),username
from users
group by username
having count(username)>1
If you want the first (or any) value of the table, and if you use mysql or postgresql, you can use the "limit x offset y" statement.
Code:
select *
from tbl
limit 1 offset 0
And finally, if you want every different values, you can use a "select distinct".
Code:
select distinct username
from users
__________________
Only a biker knows why a dog sticks his head out the window.
|