Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Back to Don't Use First Last    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
One use of First or Last
Kevin Yip 
     
3 years ago
I've found one rare use of First() or Last(), and this was from personal experience early in my career.  In a badly designed table where data aren't normalized, such as in the pictured example below, where the same customer is spelled differently in multiple rows, the only way to make an aggregate query is to use First() or Last().  In this case, the customer field can't be put under GROUP BY because the data are different.  You want the customer to be displayed, so the field has to be in the query somehow.  In an aggregate query, a field has to be either under GROUP BY or an aggregate field.  So the customer field needs to use an aggregate function.  All the other aggregate functions like Sum(), Count(), etc. can't be used, obviously.  So First() or Last() are the only options.  Since all customers are "the same," it doesn't matter which record First() or Last() uses.  Again, this is a case of bad table design.  But there may be cases where you may legitimately have non-normalized data, and First() and Last() may be useful there too.
Kevin Yip OP  @Reply  
     
3 years ago

Richard Rost  @Reply  
           
3 years ago
Indeed. But you could still use max or min in that case.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Don't Use First Last.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 2/16/2026 7:02:44 PM. PLT: 1s