Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

quesstion about FIRST 1

Status
Not open for further replies.

teach314

Technical User
Jul 29, 2011
183
CA
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)
 
FIRST is not a standard aggregate function in SQL.
You're right in saying that this function is inconsistent.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top