Need help with sorting some data

General
Teradata Employee

Re: Need help with sorting some data

You may happen to get the one you want by accident, and it may even appear to be repeatable particularly if the system isn't busy, but you can't count on it. As @Waldar said, there is no inherent order in a relational database - only the column values you can ORDER BY.

Highlighted
Enthusiast

Re: Need help with sorting some data

Thanks, Fred. Unfortunately, I don't have SAS, so I can't use that as a reference. However, I can say that when I run the above select statement, I always obtain the row with the 9999 1st, but as soon as use any sort of order by clause, the displayed table will invert its order. Maybe its just luck, but as of right now, I can't think of any solution other selecting all the top 1 rows. Just in case, is there a way to select all the top rows for every address? I'll try to figure something else out in the meantime.