Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
hi experts,
i have a table structured as below and i want to find the greatest version for each program, so for program 1 the greatest(leatest) version is 3.2.9 and for program 2 is 3.1.0.
How can i achieve this result ?
Program | Version |
---|---|
1 | 1.0.1 |
1 | 3.2.9 |
1 | 2.13.4 |
1 | 1.9.6 |
1 | 3.2.18 |
2 | 3.0.12 |
2 | 2.0.2 |
2 | 3.1.0 |
2 | 2.13.13 |
Why not ?
See Attachment.
Yes, 3.2.18 is the greatest version for program 1 but the greatest version for program 2 is 3.1.0 and not 21313 (2.13.13)
Try this:
LOAD Program,
Dual(Version, subfield(Version, '.', 1) & num(subfield(Version, '.', 2), '00') & num(subfield(Version, '.', 3), '00')) as Version
;
LOAD * Inline
[
Program,Version
1, 1.0.1
1, 3.2.9
1, 2.13.4
1, 1.9.6
1, 3.2.18
2, 3.0.12
2, 2.0.2
2, 3.1.0
2, 2.13.13
];
or simply
Data:
LOAD *,
num(SubField(Version,'.',1),'00') & num(SubField(Version,'.',2),'00') & num(SubField(Version,'.',3),'00') as Number
Inline [
Program, Version
1, 1.0.1
1, 3.2.9
1, 2.13.4
1, 1.9.6
1, 3.2.18
2, 3.0.12
2, 2.0.2
2, 3.1.0
2, 2.13.13
3, 2.7.1
3, 2.13.3];
Create straight table
Dimension:
Program
Expression:
=FirstSortedValue(Version,-Number)
Ok then one solution is this also for you kindly check once
MainTab:
LOAD *,PurgeChar(Version,'.') as ModiVersion;
LOAD * Inline
[
Program,Version
1, 1.0.1
1, 3.2.9
1, 2.13.4
1, 1.9.6
1, 3.2.18
2, 3.0.12
2, 2.0.2
2, 3.1.0
2, 2.13.13
];
MaxVersion:
LOAD
Program,
Max(ModiVersion) as MaxVer
Resident MainTab Group By Program;
MaxVerFinal:
Mapping LOAD
MaxVer,'Max Ver' as MaxFlag
Resident MaxVersion;
DROP Table MaxVersion;
NoConcatenate
Final:
LOAD
*,ApplyMap('MaxVerFinal',ModiVersion,'None') as MaxVerField
Resident MainTab;
DROP Field ModiVersion;
DROP Table MainTab;
EXIT Script;
OutPut:-
See attached also