Search code examples
coldfusionqoq

order a column in a query object by length with QoQ in ColdFusion?


Is it possible to sort a query object by the length of a varchar column using Query of Queries in ColdFusion?


Solution

  • There is no way to do this entirely with QoQ, no: the QoQ implementation does not provide a len() function. Instead, you could get the database to provide the length data for you.

    In the original query add:

    len(fieldYouNed) as fieldYouNedLen
    

    In the QoQ then use:

    SELECT * FROM query ORDER BY fieldYouNedLen