Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Help in calc in Select
Fri, Jan 19 2007 9:56 AMPermanent Link

Cicero S. Foscarini
Hello.

I need to make the same SELECT in DBIsam.


Select ((select sum(estoque.quantidade) from estoque where estoque.produto = produtos.id)
- ((select sum(consumo1.quantidade) from consumo1 where consumo1.cod_produto =
produtos.id) + (select sum(consumo3.quantidade) from consumo3 where consumo3.cod_produto =
produtos.id) + (select sum(consumo5.quantidade) from consumo5 where consumo5.cod_produto =
produtos.id))) as saldo from produtos group by id


How can I do this?


Thanks
Fri, Jan 19 2007 3:40 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Cicero,

<< I need to make the same SELECT in DBIsam. >>

You'll need to split the SELECT statements out into individual SELECT
statements that dump their results into a temporary table using the INTO
clause like this:

select produtos.id, sum(estoque.quantidade) as sum_quantidade
into "\memory\temp1"
from produtos, estoque
where estoque.produto = produtos.id
group by produtos.id

and then as the final step you'll need to re-join them all again by the
produtos.id column and perform the addition and subtraction of the summed
columns.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image