Alvinlee
26th March 2009, 14:36
Hi, All

I have the following SQLln statement and would like to group the first 5 characters of field "orno" rather than the whole field.

Select orno, sum(qoor)
from tdsls401
group by orno


Hope you can give me a advice. Thanks a lot !

A.L.

zardoz
30th March 2009, 16:22
I think isn't possible, the group by statement requires a field not an expression.

You had to find a workaround like that:


string prefix(5) fixed
domain tcqoor sum.qoor

prefix = ""
select tdsls401.orno, tdsls401.qoor
from tdsls401
order by tdsls401.orno
selectdo
if tdsls401.orno = prefix then
sum.qoor = sum.qoor + tdsls401.qoor
else
|* Use the sum.qoor and the prefix to do what you want
|* in this point, before the other statements
sum.qoor = tdsls401.qoor
prefix = tdsls401.orno(1;5)
endif
selecteos
|* and here
endselect