View Issue Details

This issue affects 1 person(s).
 0
IDProjectCategoryView StatusLast Update
20892Bug reportsStatisticspublic2026-11-24 14:44
ReporterAdamSp Assigned To 
PrioritynoneSeveritycrash 
Status newResolutionopen 
Product Version7.10.x 
Summary20892: New editor Statistics fails on SQL Server: COUNT field incorrect (named parameter :language used twice)
Description

On SQL Server (pdo_sqlsrv), the new editor's Statistics page (/editor/#/responses/<sid>/results/statistics) never shows charts. It shows "No responses or compatible data available to display statistics." and a red error toast. This happens even when the survey has completed responses.

Environment

  • LimeSurvey 7.10.0 (Docker image martialblog/limesurvey:7.10.0-261119-apache). Current master has the same code.
  • Microsoft SQL Server 2022
  • PHP pdo_sqlsrv 5.13.3, ODBC Driver 18

Steps to reproduce

  1. Install LimeSurvey with an MSSQL database.
  2. Create a survey with a list (radio) question and a 5-point question, then activate it.
  3. Complete the survey once, so there is one full response.
  4. Open the new editor, then Results, then Statistics.

Expected: charts for each question.

Actual: the "No responses or compatible data available..." message, and this error:

CDbCommand failed to execute the SQL statement: SQLSTATE[07002]:
[Microsoft][ODBC Driver 18 for SQL Server]COUNT field incorrect or syntax error.
The SQL statement executed was: SELECT [q].[qid], ... FROM [lime_questions] [q]
LEFT JOIN [lime_groups] [g] ON q.gid = g.gid
LEFT JOIN [lime_question_l10ns] [ql] ON q.qid = ql.qid AND ql.language = :language
LEFT JOIN [lime_answers] [a] ON q.qid = a.qid
LEFT JOIN [lime_answer_l10ns] [al] ON a.aid = al.aid AND al.language = :language
...

The classic statistics API (export_statistics, get_summary) works for the same survey.

Cause

QuestionStatistics::buildBaseQuery() uses the named placeholder :language twice, once in each of the two joins, and binds it once. pdo_sqlsrv doesn't support reusing a named placeholder, so the parameter count doesn't match. MySQL and PostgreSQL accept it.

application/models/services/SurveyStatistics/Charts/Questions/QuestionStatistics.php: the joins are at lines 419 and 421 in 7.10.0 and the binding is at line 428. On current master they are at lines 473, 475 and 482.

Fix

Use a separate placeholder for each use and bind both:

->leftJoin('{{question_l10ns}} ql', 'q.qid = ql.qid AND ql.language = :language')
...
->leftJoin('{{answer_l10ns}} al', 'a.aid = al.aid AND al.language = :language_al')
...
$command->params = [
':sid' => $this->surveyId,
':language' => $this->language,
':language_al' => $this->language,
];

With this change, both charts render correctly on SQL Server 2022 (checked on 7.10.0). Other queries in the new statistics and responses code may reuse a named placeholder in the same way, so they're worth checking too.

Steps To Reproduce

Steps to reproduce

(Replace this text with detailed step-by-step instructions on how to reproduce the issue)

Expected result

(Write here what you expected to happen)

Actual result

(Write here what happened instead)

TagsNo tags attached.
Bug heat0
Complete LimeSurvey version number (& build)7.10.0
I will donate to the project if issue is resolvedYes
Browser
Database type & versionMicrosoft SQL Server 2022
Server OS (if known)
Webserver software & version (if known)
PHP Version8.4.28
Git branch / Pull Request URL

Users monitoring this issue

There are no users monitoring this issue.

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2026-11-24 14:44 AdamSp New Issue