ankur0101 Posted July 9, 2013 Share Posted July 9, 2013 Hi, I have table structure as follows : Name Amount ================= John 500 John 300 John 200 Danny 250 Danny 250 ================= Now I want to fetch data according to follows : John => 1000 Danny => 500 I tried lot of logics but nothing still working perfectly. I am using codeigniter. But if I will get PHP code to fetch like that, I can manage things in codeigniter. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/279998-how-to-fetch-unique-names-from-columns/ Share on other sites More sharing options...
Solution mac_gyver Posted July 9, 2013 Solution Share Posted July 9, 2013 SELECT Name, SUM(Amount) as amt FROM your_table GROUP BY Name Quote Link to comment https://forums.phpfreaks.com/topic/279998-how-to-fetch-unique-names-from-columns/#findComment-1440050 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.