E
E
Evgeny Nikitin2014-10-01 00:07:31
SQL
Evgeny Nikitin, 2014-10-01 00:07:31

Is it possible to use group by without aggregate functions?

I have never seen that group by was used without aggregate functions, in fact, a logical question arose: "is it possible at all?", if so, please give an example.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex Chistyakov, 2014-10-01
@eunikitin

SELECT u.id, u.name, e.value FROM users u, emails e
      WHERE u.id=e.userid GROUP BY u.id, u.name

Here is a GROUP BY example without aggregate functions.
Naturally, only one lucky value will get as value from emails.

S
Sergey, 2014-10-01
Protko @Fesor

You can, of course, it just doesn’t make much sense, only together with subqueries, for example (select the last entry in a group, for example).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question