Vizonz Posted June 28, 2010 Share Posted June 28, 2010 SELECT DISTINCT songlist.count_played, songlist.ID, songlist.artist FROM radio.songlist ORDER BY songlist.count_played DESC is generating a list now how can i merge artists together and get the total out of all the count_played ? if i group it by artist it just shows me the top record. which is 24 but when not grouped there is three records.. one is 24 one is 20 and one is 12 totalling 56 Quote Link to comment https://forums.phpfreaks.com/topic/206101-need-a-little-help-with-a-query/ Share on other sites More sharing options...
dabaR Posted June 28, 2010 Share Posted June 28, 2010 SELECT player, SUM(goals) FROM match_stats WHERE player = 'dabaR'; Maybe you can modify that to your situation. Quote Link to comment https://forums.phpfreaks.com/topic/206101-need-a-little-help-with-a-query/#findComment-1078374 Share on other sites More sharing options...
Vizonz Posted June 28, 2010 Author Share Posted June 28, 2010 the where part is what messes me up. i want to get the total of songs played by artist. and show a top 10 of the artists Quote Link to comment https://forums.phpfreaks.com/topic/206101-need-a-little-help-with-a-query/#findComment-1078376 Share on other sites More sharing options...
dabaR Posted June 28, 2010 Share Posted June 28, 2010 Try: SELECT songlist.artist, SUM(songlist.count_played) FROM radio.songlist GROUP BY songlist.artist ORDER BY SUM(songlist.count_played) DESC LIMIT 10 Quote Link to comment https://forums.phpfreaks.com/topic/206101-need-a-little-help-with-a-query/#findComment-1078381 Share on other sites More sharing options...
Vizonz Posted June 28, 2010 Author Share Posted June 28, 2010 thats exactly it thanks so much i been driving my self crazy trying to figure it out Quote Link to comment https://forums.phpfreaks.com/topic/206101-need-a-little-help-with-a-query/#findComment-1078383 Share on other sites More sharing options...
dabaR Posted June 28, 2010 Share Posted June 28, 2010 You're welcome. Quote Link to comment https://forums.phpfreaks.com/topic/206101-need-a-little-help-with-a-query/#findComment-1078387 Share on other sites More sharing options...
Vizonz Posted June 28, 2010 Author Share Posted June 28, 2010 the only problem now is when i try to put php to it it leaves that count played field blank ? when i run the query it shows the results but is there something i need to do different to show that sum with php ?> Quote Link to comment https://forums.phpfreaks.com/topic/206101-need-a-little-help-with-a-query/#findComment-1078393 Share on other sites More sharing options...
dabaR Posted June 28, 2010 Share Posted June 28, 2010 Try: SELECT songlist.artist, SUM(songlist.count_played) AS count_played FROM radio.songlist GROUP BY songlist.artist ORDER BY SUM(songlist.count_played) DESC LIMIT 10 Quote Link to comment https://forums.phpfreaks.com/topic/206101-need-a-little-help-with-a-query/#findComment-1078394 Share on other sites More sharing options...
Vizonz Posted June 28, 2010 Author Share Posted June 28, 2010 there we go perfect thanks again much appreciated Quote Link to comment https://forums.phpfreaks.com/topic/206101-need-a-little-help-with-a-query/#findComment-1078396 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.