johnsmith153 Posted October 7, 2010 Share Posted October 7, 2010 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) Quote Link to comment https://forums.phpfreaks.com/topic/215382-limit-a-group-by-query/ Share on other sites More sharing options...
eran Posted October 7, 2010 Share Posted October 7, 2010 GROUP BY Department? You can also use SELECT DISTINCT Department FROM $table Quote Link to comment https://forums.phpfreaks.com/topic/215382-limit-a-group-by-query/#findComment-1120030 Share on other sites More sharing options...
johnsmith153 Posted October 8, 2010 Author Share Posted October 8, 2010 My example was complete rubbish. I am trying a bigger problem but wanted to use something scaled down to make it easier to explain. I'll close this and start a new post - as it's very different. Thanks anyway. Quote Link to comment https://forums.phpfreaks.com/topic/215382-limit-a-group-by-query/#findComment-1120037 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.