For (each/first/last) by date

Jordi

New Member
for each prh_hist no-lock
where prh_domain = "ITS1"
and prh_nbr = "28601004"
and prh_line = 1
and prh_ps_nbr = "007021"
by prh_rcp_date
:
display
prh_rcp_date
.
end.

┌─────┐
│Receipt │
│─────│
│11/08/23│
│03/08/24│
└─────┘

for each prh_hist no-lock
where prh_domain = "ITS1"
and prh_nbr = "28601004"
and prh_line = 1
and prh_ps_nbr = "007021"
by prh_rcp_date desc
:
display
prh_rcp_date
.
end.

┌─────┐
│Receipt │
│─────│
│03/08/24│
│11/08/23│
└─────┘

for first prh_hist no-lock
where prh_domain = "ITS1"
and prh_nbr = "28601004"
and prh_line = 1
and prh_ps_nbr = "007021"
by prh_rcp_date
:
display
prh_rcp_date
.
end.

┌─────┐
│Receipt │
│─────│
│03/08/24│
└─────┘

for first prh_hist no-lock
where prh_domain = "ITS1"
and prh_nbr = "28601004"
and prh_line = 1
and prh_ps_nbr = "007021"
by prh_rcp_date desc
:
display
prh_rcp_date
.
end.

┌─────┐
│Receipt │
│─────│
│03/08/24│
└─────┘

for last prh_hist no-lock
where prh_domain = "ITS1"
and prh_nbr = "28601004"
and prh_line = 1
and prh_ps_nbr = "007021"
by prh_rcp_date
:
display
prh_rcp_date
.
end.

┌─────┐
│Receipt │
│─────│
│11/08/23│
└─────┘

for last prh_hist no-lock
where prh_domain = "ITS1"
and prh_nbr = "28601004"
and prh_line = 1
and prh_ps_nbr = "007021"
by prh_rcp_date desc
:
display
prh_rcp_date
.
end.

┌─────┐
│Receipt │
│─────│
│11/08/23│
└─────┘
 
Last edited:

Jordi

New Member
Hi all,

When using the FOR EACH, I can see that both results are correct (using DESCEDING or not using it).

But when using FOR FIRST or FOR LAST, results are not ok.

When using FOR FIRST I always obtain the record 03/08/24, whether I use DESCEDING or not.

When using FOR LAST I always obtain the record 11/08/23, whether I use DESCEDING or not.

Do you know why I'm having these results?

Thank you very much.

Regards,

Jordi
 
Top