Skip to main content
WolfShade
Legend
October 18, 2017
Answered

QoQ and modulus?

  • October 18, 2017
  • 2 replies
  • 1590 views

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 has been closed for replies.
    Correct answer EddieLotter

    I created a quick test and got the same error.

    It appears the modulus operator is not supported in QoQ.

    Cheers

    Eddie

    2 replies

    BKBK
    Community Expert
    Community Expert
    October 19, 2017

    WHERE cola MOD 2 = 0

    EddieLotter
    Inspiring
    October 19, 2017

    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

    BKBK
    Community Expert
    Community Expert
    October 19, 2017

    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.

    EddieLotter
    EddieLotterCorrect answer
    Inspiring
    October 18, 2017

    I created a quick test and got the same error.

    It appears the modulus operator is not supported in QoQ.

    Cheers

    Eddie

    WolfShade
    WolfShadeAuthor
    Legend
    October 19, 2017

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

    V/r,

    ^ _ ^

    EddieLotter
    Inspiring
    October 19, 2017

    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