Get sum fuction?[SOLVE]

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Get sum fuction?[SOLVE]

Post by jayson.ph »

Hi, all

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

please help.
Last edited by jayson.ph on Mon Jul 02, 2012 2:48 am, edited 1 time in total.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Get sum fuction?

Post by requinix »

A JOIN to bridge the tables and simple addition for the sum.
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Re: Get sum fuction?

Post by jayson.ph »

ah can i have a syntax...

Image
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Get sum fuction?

Post by requinix »

Considering how easy it is to find out how to write a JOIN, no.
User avatar
jayson.ph
Forum Contributor
Posts: 165
Joined: Mon Jan 02, 2012 9:20 am
Location: MP
Contact:

Re: Get sum fuction?

Post 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]'";
Post Reply