How to get the total of Database columns through SQL Query

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

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

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: 1803
Joined: Thu Mar 10, 2011 5:07 pm

Thu Jun 27, 2013 3:41 am

do a select emp_id, name, sum(tt) as TT from table_name group by emp_id

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests