Re: [GENERAL] Help : Sum 2 tables based on key from other table

2013-11-18 Thread Robin St . Clair
Hi For decades, this type of problem has been the meat and vegetables of discussions about SQL programming and design. One writer on this subject has stood out, thanks to his mental clarity and ability to set out complicated concepts in a readily comprehensible manner. His name is Joe

Re: [GENERAL] Help : Sum 2 tables based on key from other table

2013-11-18 Thread Raymond O'Donnell
On 18/11/2013 02:16, Hengky Liwandouw wrote: Dear Friends, Please help for the select command, as i had tried many times and always can not display the result as what i want. I am looking for the solution on google but still can not found the right answer to solve the problem. I have 3

Re: [GENERAL] Help : Sum 2 tables based on key from other table

2013-11-18 Thread Ken Tanzer
If the tables aren't huge, you're not concerned about optimization, and you just want to get your numbers, I think something like this would do the trick. I haven't actually tried it 'cause I didn't have easy access to your tables: SELECT a.product_id, a.product_name, b.initial_stock_sum,

Re: [GENERAL] Help : Sum 2 tables based on key from other table

2013-11-18 Thread Hengky Liwandouw
Thanks all for your concern and help. I have tried David suggestion and it works. As what you all said, there are so many important feature in PostgreSQL. I really have to spend time to study it. Last time i use Windev to develop front end application, and HyperfileSQL as the database server.

Re: [GENERAL] Help : Sum 2 tables based on key from other table

2013-11-18 Thread Hengky Liwandouw
Thanks a lot Ken, I will try it soon. But when the table becomes huge (how big 'huge' in postgres ?), how to optimize such command ? I have index on all important field like date, productid, supplierid, customerid and so on Optimization is really an important thing as i plan to keep all

Re: [GENERAL] Help : Sum 2 tables based on key from other table

2013-11-18 Thread Robin St . Clair
In general, when I have to handle Ledger type data (which this problem is), I tend to hold data in 3 tables 1. Master Ledger ( Product ID, Name, etc) 2. Master Ledger Balances(Product ID, Fiscal_Year, Opening Balance, Net_Transaction_P1, Net_Transaction_P2, ... etc) 3. Master Ledger

Re: [GENERAL] Help : Sum 2 tables based on key from other table

2013-11-18 Thread Elliot
On 2013-11-18 04:37, Ken Tanzer wrote: If the tables aren't huge, you're not concerned about optimization, and you just want to get your numbers, I think something like this would do the trick. I haven't actually tried it 'cause I didn't have easy access to your tables: SELECT

[GENERAL] Help : Sum 2 tables based on key from other table

2013-11-17 Thread Hengky Liwandouw
Dear Friends, Please help for the select command, as i had tried many times and always can not display the result as what i want. I am looking for the solution on google but still can not found the right answer to solve the problem. I have 3 tables : Table A ProductID