Skip to main content
WolfShade
Legend
Oct 18, 2017 8:01 PM UTC
Answered

QoQ and modulus?

Hello, all,

I have been trying to use a modulus in a QoQ, and it's not working.

SELECT cola, colb, colc

FROM queryName

WHERE cola % 2 = 0

/* cola is an integer 1 - 10 */

.. and I get..

Encountered "cola 2 =. Incorrect conditional expression, Incorrect conditional expression, Lexical error at line 1, column 45. Encountered: " " (32), after : "%"

The error occurred on line 445.

(There are 16 lines of code, so I assume that the line 445 is in query.cfc.)

Can you use % or mod() in a QoQ???

V/r,

^ _ ^

    This topic is closed to new replies. Start a new post to keep the conversation going.
    EddieLotter
    EddieLotterCorrect answer
    Inspiring
    Oct 18, 2017 9:13 PM UTC

    I created a quick test and got the same error.

    It appears the modulus operator is not supported in QoQ.

    Cheers

    Eddie

    19 replies

    BKBK
    Community Expert
    Community Expert
    Oct 19, 2017 2:50 PM UTC

    WHERE cola MOD 2 = 0

    Translate
    EddieLotter
    Inspiring
    Oct 19, 2017 2:57 PM UTC

    BKBK  wrote

    WHERE cola MOD 2 = 0

    That gives the lovely message:

    Encountered "MOD 2. Incorrect conditional expression, Expected one of [like|null|between|in|comparison] condition, Unrecognized comparison operator,

    Note further that the message opens a double-quote but does not close it and ends with a comma.

    Cheers

    Eddie

    Translate
    BKBK
    Community Expert
    Community Expert
    Oct 19, 2017 3:44 PM UTC

    There's really no modulus operator in query-of-query? I am surprised - and a bit disappointed. @Wolfshade, let us know when you're done with the feature request. Then we can vote for it.

    Translate
    EddieLotter
    EddieLotterCorrect answer
    Inspiring
    Oct 18, 2017 9:13 PM UTC

    I created a quick test and got the same error.

    It appears the modulus operator is not supported in QoQ.

    Cheers

    Eddie

    Translate
    WolfShade
    WolfShadeAuthor
    Legend
    Oct 19, 2017 2:01 PM UTC

    Bummer.  I'll go and submit a feature request, coz that could definitely come in handy.

    V/r,

    ^ _ ^

    Translate
    EddieLotter
    Inspiring
    Oct 19, 2017 2:08 PM UTC

    If you are populating the query from a database and then using QoQ to process the database query results, an interim solution to your scenario would be to add a column using the modulus operator in your database query. You can then use that additional column's value as a simple integer in your QoQ.

     

    Cheers

    Eddie

    Translate