| Subject |
Re: Total on in dbase 8.0 |
| From |
Mervyn Bick <invalid@invalid.invalid> |
| Date |
Wed, 7 Oct 2020 14:38:38 +0200 |
| Newsgroups |
dbase.getting-started |
On 2020/10/07 11:31, Rouke wrote:
> I'm trying to do a simple Total on operation in dbase 8.0, but am not getting results I expect:
>
> On the following table:
>
> set fields to typetota = ltrim(str(year(received)))+ltrim(str(month(received)))+testtype
> set fields to numbers,received,testtype
>
> TYPETOTA NUMBERS RECEIVED TESTTYPE
> 2011764 1.0000 27/07/2011 64
> 2011964 1.0000 07/09/2011 64
> 2012101 1.0000 23/10/2012 1
> 2012101 1.0000 23/10/2012 1
> 2012101 1.0000 23/10/2012 1
> 2012101 1.0000 23/10/2012 1
> 2012101 1.0000 23/10/2012 1
> 2012101 1.0000 23/10/2012 1
> 20121010 1.0000 04/10/2012 10
>
> I do:
> index on ltrim(str(year(received)))+ltrim(str(month(received)))+testtype tag typetota
> total on typetota field numbers to lbplmdl2
Firstly NEVER index on trimmed values unless you also make sure to pad
the entire expression so that it is the same length for each record.
All index values MUST be the same length.
Instead of typetota =
str(year(received),4,0,'0')+str(month(received),2,0,'0') you can use dtos()
typetota = substr(dtos(received),1,6)
use your_file_name excl
index on substr(dtos(received),1,6)+str(val(testtype),2,0,'0') tag typetota
set fields to typetota =
substr(dtos(received),1,6)+str(val(testtype),2,0,'0')
set fields to numbers,received,testtype
total on typetota to lbplmdl2
use lbplmdl2
browse
Mervyn.
|
|