Details
-
Improvement
-
Status: Open
-
Not a Priority
-
Resolution: Unresolved
-
None
-
None
Description
SELECT c1, c2, c3, c4 FROM ( SELECT *,ROW_NUMBER() OVER (PARTITION BY c1, c2, c3 ORDER BY c4 DESC) AS rownum FROM t ) WHERE rownum <= 1
This SQL is Top 1, Top N produce stream with primary keys contains row number, but your sql didn't select row number, so there is not primary key.
But for Top 1, we can produce primary key, because row number is always 1.