Re: Sorting integer field
Posted in 1993
In article <1lu9flINN68s@emory.mathcs.emory.edu> RUCHI@CFRVM.CFR.USF.EDU writes:
>I have an integer field that I like to sort using the LAST 2 NUMBERS on
>integer field. For example:
>
>Before Sorting the values looks like the following:
>1
>2
>9
>107
>202
>204
>10
>
>After Sorting the values should look like the following:
>1
>2
>202
>204
>107
>9
>10
>
>Any idea? solution? Please help
>Thanks.
>Ruchi.
If this is for 4GL reports, there's an easy solution:
define intwork char(3), last2 char(2)
declare x cursor for select intfield, .... from tablename
foreach x into rec.intfield, ...
let intwork = rec.intfield using "&&&"
let last2 = intwork[2,3]
output to report reportname (last2, rec.*)
end foreach
...
report reportname(sortme, rec.*)
define sortme char(2), rec record like XXXXXXXX
order by sortme
...
end report
OR, in SQL, IF you have a 5.XX engine product, you can take advantage
of the mod() function:
select intfield, mod(intfield, 100) last2 from tablename
order by last2
--
Alan Denney aland@informix.com {pyramid|uunet}!infmx!aland
"The disparity between the treatment of Ron Brown and the treatment of
Zimba (sic) Wood or Zoe Baird I think is rather dramatic."
-- Patricia Ireland, NOW President, 2/8/93