Hi everybody,
I am usng MYSQL version 4.1 and PHP 5.0 on windows XP.
I had some date related to sales, purchase and payment.
Now I want to convert that in PHP-MYSQL based software application.
I have four tables in a database. Tables and there structures are:
TABLE sale: client(varchar,100),item(varchar,10),date(datetime ),rate(dcimal,14,2),quantity(decimal,14,2),deducti on1(decimal,14,2),deduction2(decimal,14,2),addtion (decimal,14,2)
TABLE purchase: client(varchar,100),item(varchar,10),date(datetime )rate(dcimal,14,2),quantity(decimal,14,2),deductio n1(decimal,14,2),deduction2(decimal,14,2),addtion( decimal,14,2)
TABLE payment: client(varchar,100),item(varchar,10),date(datetime ),amount(decimal,14,2),purpose(varchar,100)
TABLE client: client(varchar,100)parimary key
client table stores data of distinct clients.
sale table stores data of various clients, amount, date.
purchase table stores data of various clients, amount, date.
daily table stores data of various clients, ampunt paid, date.
Now I want an outstanding report for each client, for sale and purchase independantly.
Like in these column structure:
CLIENT TOTALSALES PAID DUE
A 100 50 50
B 450 100 350
I am running this euery:
#########################CODE##################### ##
SELECT DISTINCT sale.client, SUM(sale.amount), SUM(daily.amount) FROM
purchase, daily WHERE sale.client = daily.client
########################CODE###################### ##
BUt ende up with wrong results. pls help with proper query