Danlo Magician
Joined: 28 Nov 2003 Posts: 313 Location: Australia
|
Posted: Mon Dec 22, 2003 9:49 am |
I am assuming the 2 fields are called Name and Value. I had a problem with this, whereby %dbmax() didn't set %rec to the record with the maximum Value. Hopefully, if you use the newest version, it should be ok.
#var sortedrecords {%null}
#var recordvalues {%null}
#LOOP %numrec() {#NOOP {%dbmax(value)}
#var sortedrecords {%additem(%db(%rec,name),@sortedrecords)}
#var recordvalues {%additem(%db(%rec,value),@recordvalues)}
#addkey Value 0}
#DBRESET
#FORALL @sortedrecords {#LOOPVIEW {#IF (%db(%rec,Name) = "%i") {#addkey Value %item(@recordvalues,1)
#delnitem recordvalues 1} {}} |
|