Print Page | Close Window

What is the best practice for "Select Max(field) from table where conditions" with ideablade query l

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=268
Printed Date: 13-Mar-2025 at 5:37pm


Topic: What is the best practice for "Select Max(field) from table where conditions" with ideablade query l
Posted By: Customer
Subject: What is the best practice for "Select Max(field) from table where conditions" with ideablade query l
Date Posted: 16-Jul-2007 at 11:17am

What is the best practice for "Select Max(field) from table where conditions" with ideablade query language?




Replies:
Posted By: IdeaBlade
Date Posted: 16-Jul-2007 at 11:22am
This is one case where it might be best NOT to use OQL because you will have to retrieve all of the records in the table from the Server to the Client, and then compare the field of interest for each row of the table.  This is definitely slower than using a passthrough query using the MAX function.
 
If you must use OQL, then I would create a dynamic entity with 2 columns.  One column would be the primary key column, and the second column woulld be the column you were trying to find the MAX function.  You still are retrieving all of the records in the table, but you are retrieving only two columns of the table instead of all of the columns.
 
If you are not quite sure how to query against dynamic entities, look at the Developer's Guide.  There is also a Tutorial on Dynamic Entities.



Print Page | Close Window