SQL table represent unordered sets. Without an explicit sort, the rows are in arbitrary order. If the sort keys are not unique, then ties are in an arbitrary order.
Then, you don't need to repeat the PARTITION BY key in the ORDER BY for window functions. You could write what you want in Oracle as:
select RANK() OVER (PARTITION BY EQUIP_UNIT_INIT_CODE ORDER BY ROWNUM)
from CAR_SEARCH_GTT;
Despite the rownum, the ordering is arbitrary. Oracle makes no guarantee on the ordering within each group.
The one effect of rownum is to have a different value on each row. Hence, there are no ties. This is more clearly expressed using ROW_NUMBER():
select ROW_NUMBER() OVER (PARTITION BY EQUIP_UNIT_INIT_CODE ORDER BY ROWNUM)
from CAR_SEARCH_GTT;
Oracle requires an ORDER BY clause, so anything can go there.
In Postgres, you can do the same thing by removing the ORDER BY -- Postgres extends the syntax of ROW_NUMBER. So the equivalent is:
select ROW_NUMBER() OVER (PARTITION BY EQUIP_UNIT_INIT_CODE)
from CAR_SEARCH_GTT;
In both cases, you might have an appropriate key for ordering -- perhaps an identity column or creation date.
order byon the overallselect? The reason I ask is because Oracle generatesrownumbased on theorder.partition byandorder bystill makes no sense.