Suppose you have a schema called mySchema and a table called myTable. You would like to retrieve all data with maximum length (for instance, whose first name is the longest).
The following is a simple query to handle situations like this.
select * from mySchema.myTable where length(myTable.firstName)= (select max(length(myTable.firstName)) from mySchema.myTable
Simple Huh ! Well it sometimes saves you a minute. The functions are tested to work in DB2/AS-400[My Video Promotion]
More from: SQL Code
- How to setup and run the Microsoft’s Command Line BCP Utility Without Installing SQL Server Client?
- Utility Class For Getting SQL Connection and Closing It
- Dropping Stored Procedure and Granting Execute Permission
- Finding MAX length of the data in DB column
- SQL – How To Find The Physical Location Of MySQL Database (Data Location)
- Quick SQL Reference – Find Duplicate Data In A Table Using Having Clause
- 005: MySQL – Selecting a set of random rows from a table
- SQL – Finding Nth Highest Row In DB Table
- SQL – How To Retrieve Data With Maximum Length?