Jump to content

LIMIT a GROUP BY query


johnsmith153

Recommended Posts

I want to limit so it only returns one record of each group when using GROUP BY.

 

Department / Name / Sales

 

A / Dave / 303

A / Steve / 313

A / Rob / 311

B / John / 308

B / Kate / 306

B / Mark / 310

 

SELECT Department FROM $table GROUP BY A (but return only one per Department) ORDER BY Sales

 

.. so it would return

 

A / Steve / 313

B / Mark / 310

(and no other records)

Link to comment
https://forums.phpfreaks.com/topic/215382-limit-a-group-by-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.