Discussions
Join us for complimentary one-day events around the world and step into a future fueled by AI and limitless potential. Explore new breakthroughs, sharpen your skills, and connect with experts who are shaping what’s next. Experience bold keynotes, interactive learning, and connections that span the global NetSuite community. Discover what's next at SuiteConnect Tour 2026.
NetSuite has launched SuiteSuccess Wholesale Distribution Edition, in Japan. Please join us the webinar on February 12 that introduces NetSuite solution with demos and case studies for Wholesale Industry.
Register Now
SQL Essentials: KEEP Function Explained
Overview
The KEEP() function in SQL is used in conjunction with aggregate functions to return specific values from a group of rows based on a defined ordering. In simpler terms, it allows you to extract a particular value (such as the first or last entry) within a grouped dataset, according to a specified sort order. This is particularly useful when you need to retrieve the most recent or earliest record in a set, like identifying the latest transaction for each customer.
Understanding the Syntax
The general syntax for using the KEEP() function with an aggregate function is:
AGGREGATE_FUNCTION(column_name) KEEP (DENSE_RANK FIRST | LAST ORDER BY column_name)
Learn how to Refer A Member | Earn the Answer Accepter Badge | Be the Content Creator of the Quarter | Vote for the content you want to see!
