bumerang
30th January 2002, 14:55


select tibom902.citg, sum(tibom902.cost * tibom902.groq)
from tibom902
group by tibom902.citg
selectdo
....
endselect

We need to run a SELECT like above, But it doesn't work . Because sum(tibom902.cost * tibom902.groq) line gives error .

How can we use multiply operation in Sum command

Or

can we do This Select other way ?

Thank for help
:confused:

Youp2001
30th January 2002, 16:34
You can always do it in within the selectdo of your query so

result = 0
hold.citg = ""

select tibom902.citg, tibom902.cost, tibom902.groq
from tibom902
where ...
order by ...
selectdo
if tibom902.citg <> hold.citg then
| New citg
if not isspace(hold.citg) then
| Do something with the result of the previous citg
...
endif
hold.citg = tibom902.citg
result = tibom902.cost * tibom902.groq
else
result = result + (tibom902.cost * tibom902.groq)
endif
selecteos
| Do something with the last result
.....
endselect

bumerang
31st January 2002, 09:58
We solved our problem below to with with 2th. select
thank you for help

citg_cost = 0
select tibom902.citg,tcmcs023.dsca
from tibom902 , tcmcs023
where tibom902.citg >= :itemg.f
and tibom902.citg <= :itemg.t
and tibom902.citg refers to tcmcs023
group by tibom902.citg,tcmcs023.dsca
selectdo
select tibom902.citg,tibom902.cost,tibom902.groq
from tibom902
where tibom902.citg = :tibom902.citg
and tibom902.kitm = tckitm.purchase
selectdo
citg_cost = citg_cost + (tibom902.cost * tibom902.groq)
endselect

k.of.data = "bom"
print.record(1)
citg_cost = 0

endselect