Q:

Invalid Column Index Error - Unable to resolve the issue

This is how my XML looks like. All the properties defined has respective getters and setters defined. I am unable to resolve the "Invalid Column index" issue after trying various suggestions. 
The SELECT statement returns all the properties listed appropriately and I have verified the same running as separate Query. 
I am fetching data from set of tables for a particular Group between a specified Date Range.

    <resultMap id="result" type="ValueStats">
        <result property="GroupId" column="GROUP_ID"/>
        <result property="valueId" column="VALUE_ID"/>
        <result property="valueName" column="VALUE_NAME"/>
        <result property="valImp" column="IMP"/>
        <result property="valCks" column="CKS"/>
        <result property="valCR" column="CR"/>
        <result property="valAp" column="AP"/>
        <result property="valRv" column="RV"/>
        <result property="valCt" column="CT"/>
        <result property="fromDate" column="FROM_DATE"/>
        <result property="toDate" column="END_DATE"/>
        <result property="valKc" column="KC"/>
    </resultMap>

    <select id="getAll" resultMap="result">
        SELECT 
              B.GROUP_ID AS GROUP_ID,
              B.VALUE_ID AS VALUE_ID,
          B.VALUE_NAME AS VALUE_NAME,
          A.IMP AS IMP, 
          A.CKS AS CKS,
          A.CR AS CR,
          A.AP AS AP,
          A.RV AS RV,
          A.CT AS CT,
          #{fromDate} AS FROM_DATE,
          #{toDate} AS END_DATE,
          A.KC AS KC
        FROM
        (SELECT 
              Z.VALUE_ID AS VALUE_ID,
              ROUND(AVG(Z.IMP), 0) AS IMP, 
              ROUND(CEIL(AVG(Z.CKS)),0) AS CKS, 
              ROUND(AVG(Z.CR),5) AS CR,  
              ROUND(AVG(Z.AP),2) AS AP,
              ROUND(AVG(Z.CT),2) AS CT, 
              ROUND(AVG(Z.RV),2) AS RV,
              ROUND(COUNT(Z.VALUE_ID)) AS KC
              FROM
                (SELECT 
                  VALUE_ID AS VALUE_ID, 
                  IMP AS IMP, 
                  TO_DATE(DATE_ID,'YYYYMMDD') AS DATEVAL, 
                  CKS, 
                  CR, 
                  AP, 
                  CT, 
                  RV
            FROM XY_STATS WHERE GROUP_ID='#{groupId}') Z
            WHERE
            Z.DATEVAL <![CDATA[<]]> TO_DATE(#{toDate}, 'DD-MM-YY') AND
            Z.DATEVAL >= TO_DATE(#{fromDate}, 'DD-MM-YY') 
            GROUP BY Z.VALUE_ID) A INNER JOIN XY_VALUE_SETTINGS B
            ON A.VALUE_ID = B.VALUE_ID
    </select>

A:

You have quotes around a dynamic value:  
...
FROM XY_STATS WHERE GROUP_ID='#{groupId}') Z
...  

the prepared statement will replace the value with other quotes.

