How to get the total of Database columns through SQL Query

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

stephenrodrics
New php-forum User
New php-forum User
Posts: 58
Joined: Thu Mar 14, 2013 6:10 am

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

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

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


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 3 guests

cron