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

Get sum fuction?[SOLVE]

Postby jayson.ph » Sun Jul 01, 2012 11:06 pm

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
jayson.ph
Forum Contributor
 
Posts: 165
Joined: Mon Jan 02, 2012 10:20 am
Location: MP

Re: Get sum fuction?

Postby requinix » Sun Jul 01, 2012 11:36 pm

A JOIN to bridge the tables and simple addition for the sum.
The terror of immortality is eternal solitude. An endless reality tormented by the consciousness of one's sins.
User avatar
requinix
Spammer :|
 
Posts: 4836
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Get sum fuction?

Postby jayson.ph » Mon Jul 02, 2012 12:03 am

ah can i have a syntax...

Image
User avatar
jayson.ph
Forum Contributor
 
Posts: 165
Joined: Mon Jan 02, 2012 10:20 am
Location: MP

Re: Get sum fuction?

Postby requinix » Mon Jul 02, 2012 12:30 am

Considering how easy it is to find out how to write a JOIN, no.
The terror of immortality is eternal solitude. An endless reality tormented by the consciousness of one's sins.
User avatar
requinix
Spammer :|
 
Posts: 4836
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Get sum fuction?

Postby jayson.ph » Mon Jul 02, 2012 1:50 am

i trying this: but why all i receive get all total. please help
Syntax: [ Download ] [ Hide ]
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]'";
User avatar
jayson.ph
Forum Contributor
 
Posts: 165
Joined: Mon Jan 02, 2012 10:20 am
Location: MP


Return to Databases

Who is online

Users browsing this forum: No registered users and 1 guest