Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

How to get the total of Database columns through SQL Query

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

How to get the total of Database columns through SQL Query

Postby stephenrodrics » Thu Jun 27, 2013 2:22 am

I want to get the total for TT for SAM and ID total for SAM

Similarly total for John TT

EmpID Name STID TT ID Book Week
245 John '0 84 '0 '0 '2013-06-05
245 John '0 80 '0 '0 2013-06-12
2303 SAM '0 80 12 12 '2013-06-05
2303 SAM '0 20 12 '0 2013-06-12


I want output such as


EmpID Name STID TT ID

245 John '0 164 '0
2303 SAM '0 100 24 12
stephenrodrics
New php-forum User
New php-forum User
 
Posts: 58
Joined: Thu Mar 14, 2013 6:10 am

Re: How to get the total of Database columns through SQL Que

Postby johnj » Thu Jun 27, 2013 3:41 am

do a select emp_id, name, sum(tt) as TT from table_name group by emp_id
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to PHP coding => General

Who is online

Users browsing this forum: dendonpaul, Google Feedfetcher and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.