vinayraj
2nd February 2012, 07:44
Hi,
I'm using a Baan4 c4 erp application, now i'm working on script. i wanted to declare a varibles for the element of the first and last records, fetched from table e.g
select tccom010.*
from tccom010
where tccom010.creg between :creg.f and creg.t
here i get no. of records for the tccomo10.cuno (customer no). now i wanted to declare a varible for the cuno of 1sr row and cuno of last row at script leval. how this can be done ??? plz help
Thanking you very much..

ragards
vinayraj.

mark_h
2nd February 2012, 15:34
Not sure I understand what you are trying to do. It almost sounds like what you want is:

select tccom010.creg, count(tccom010.cuno):rec.count
from tccom010
where tccom010.cred inrange :creg.f and :creg.t
group by tccom010.creg
selectdo
endselect


Not sure why you need the first or last cuno. But you can get that by adding a sort and a as set with 1 rows.


select tccom010.creg, count(tccom010.cuno):rec.count
from tccom010
where tccom010.cred inrange :creg.f and :creg.t
group by tccom010.creg
order by tccom010.creg
as set with 1 rows
selectdo
endselect

Then to get last cuno:

select tccom010.creg, count(tccom010.cuno):rec.count
from tccom010
where tccom010.cred inrange :creg.f and :creg.t
group by tccom010.creg
order by tccom010.creg desc
as set with 1 rows
selectdo
endselect

Hope this helps.

vinayraj
3rd February 2012, 05:59
hi mark,
Thanx for the useful querry.

_----------------
vinayraj