Select question
Posted in 1996
Topics: General Discussion
Hi all, I have a question about a general problem(?) I have a database which is something as: nr amountA amountB A 100 70 B 110 75 C 80 60 D 90 50 What I want is to substract amountB for nrs C and D from amountA for nrs A and B: something like select sum(first.amountA - second.amountB) from table first, table second where first.nr in (A,B) and second.nr in (C,D) I want the outcome 100 + 110 - 60 - 50, I get the outcome 100 + 110 - 60 - 50 + 100 + 110 - 60 - 50: everything in (A,B) gets counted as often as it can be combined with everything in (C,D) and the other way around. I can eliminate one double counting with the use of 'distinct'. How can I eliminate all double countings? (Especially when I combine (A,B,C,D,E) with (F,G,H) or more complex.) -- All replys will be appreciated a lot. Mazzel, cheers, bye, tabe, moi, tot ziens, have a nice day, Koos ____________________________________________________________________ JJ Schut | e-mail: schut@th.rug.nl | Institute for Theoretical Physics | | University of Groningen | Phone: +31 50 5999905 | P.O. Box 800 | Phone: +31 50 3138172 | 9700 AV Groningen, The Netherlands. | Fax: +31 50 5999984 | | Yell: Very, Very loud | --------------------------------------------------------------------