Getting info out of a table

chefsride

Member
I am trying to take a table that has a date field called start-date with many dates for each client called client-id. I want to find the earliest date in the start-date field and create a temp-table with that earliest date and there client-id.
 
Here's a way i did it - the slow way.
Code:
define var v-client id like urTABLE.client-id.

define temp-table urTmpTable
		 field client-id like urTABLE.client-id
		 field start-date like urTABLE.start-date.

v-client = "".

for each urTABLE by client-id by start-date:
   if v-client = urTABLE.client-id then next.
   if v-client <> urTABLE.client-id then do:
	  v-client = urTABLE.client-id.
	  create urTmpTable.
	  urTmpTable.client-id = urTABLE.client-id.
	  urTmpTable.start-date = urTABLE.start-date.
	end.
end.

for each urTmpTable:
	 display urTmpTable.
end.
 
typo in that first post defining v-client var
but don't listen to me, i've been doing this for only a few months

but, here's one better

for each urTable break by client-id by start-date:
if FIRST-OF (client-id) then
display client-id start-date
end.
 
Back
Top