Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Question in open SQL for Ztable

Former Member
0 Likes
301

Hello All,

I have a Z table and there is SQL that get's the latest record from the Ztable.

SELECT * FROM ZXXX WHERE TYPE = '01'. ENDSELECT.

For example there is a column called template in this Z table whose 1st record has value 100001 and last record has value 100029. Yesterday the SQL above was getting the latest record for example 100029 and today I run the same SQL and it is not getting the latest record!! It get's some other record from the middle for example with value 10001! Is there any reason why this behavior happens? Any suggestions please..

Thanks.

Mithun

1 REPLY 1
Read only

Former Member
0 Likes
276

The order in which data is returned is not guaranteed uless you specify an order. Try :

SELECT * FROM zxxx
  UP TO 1 ROWS
  WHERE type = '01'
  ORDER BY zz_field DESCENDING.

ENDSELECT.

Rob