Page 1 of 1

Get sum fuction?[SOLVE]

Posted: Sun Jul 01, 2012 11:06 pm
by jayson.ph
Hi, all

how to get a sum of two field in different table.?

please help.

Re: Get sum fuction?

Posted: Sun Jul 01, 2012 11:36 pm
by requinix
A JOIN to bridge the tables and simple addition for the sum.

Re: Get sum fuction?

Posted: Mon Jul 02, 2012 12:03 am
by jayson.ph
ah can i have a syntax...

Image

Re: Get sum fuction?

Posted: Mon Jul 02, 2012 12:30 am
by requinix
Considering how easy it is to find out how to write a JOIN, no.

Re: Get sum fuction?

Posted: Mon Jul 02, 2012 1:50 am
by jayson.ph
i trying this: but why all i receive get all total. please help

Code: Select all

SELECT tbl_recieve.id,
						tbl_recieve.uid,
						tbl_recieve.cat_name,
						tbl_recieve.product_name,
						tbl_recieve.product_model,
						tbl_recieve.rec_on,
						tbl_recieve.return_on,
						tbl_recieve.sold,
						sum(tbl_recieve.balancs)as Balance FROM tbl_recieve INNER JOIN tbl_adm_rpl ON tbl_recieve.id = 'id' group by tbl_recieve.balancs order by Balance, 
						tbl_recieve.re_qty,
						tbl_recieve.dt_nwo,
						tbl_recieve.dt_response,
						tbl_recieve.commnt,
						tbl_recieve.dt_recve,
						tbl_user.uid,
						tbl_user.tbl_brnch_name,
						tbl_user.f_name
						FROM tbl_recieve INNER JOIN tbl_user ON tbl_recieve.uid = tbl_user.uid WHERE tbl_recieve.uid = '$_SESSION[SESS_MEMBER_ID]'";