I've seen in several places of this forum that tables have no inherent order. When a table is displayed, it obviously has an order on the screen, but that order is not logically imposed by the data. Given that, what does it really mean to use FIRST when writing SQL?
The only place I really use it is sometimes when using GROUP BY. Let's say I have a table like this.
A B C
1 12 8
1 12 10
2 12 33
2 12 5
......
1000 12 45
1001 12 etc
If the SQL includes a GROUP BY A, it might be a tiny bit more efficient to use FIRST(B) in the SELECT statement instead of MIN(B) for example, because we don't have to scan all the values B values.
in any case, I'm just wondering about how the SQL gurus intended FIRST to be used - it seems to be inconsistent with the unordered nature of tables. (I guess all of this would apply to LAST as well)
The only place I really use it is sometimes when using GROUP BY. Let's say I have a table like this.
A B C
1 12 8
1 12 10
2 12 33
2 12 5
......
1000 12 45
1001 12 etc
If the SQL includes a GROUP BY A, it might be a tiny bit more efficient to use FIRST(B) in the SELECT statement instead of MIN(B) for example, because we don't have to scan all the values B values.
in any case, I'm just wondering about how the SQL gurus intended FIRST to be used - it seems to be inconsistent with the unordered nature of tables. (I guess all of this would apply to LAST as well)