php - Inline declared MySQL 'unknown column' -
here's script i'm trying run:
$resultadospromediados = r::getall("select count(*) total, sum(dialogue_score) / total dialogue_score, sum(consulta_general_score) / total consulta_general_score, sum(tarea_score) / total tarea_score, sum(foro_calificacion_score) / total foro_calificacion_score, sum(foro_respuesta_score) / total foro_respuesta_score ranking created = :ultima_feha", array(':ultima_feha' => $fecha)); print_r($resultadospromediados);
but error:
fatal error: uncaught [42s22] - sqlstate[42s22]: column not found: 1054 unknown column 'total' in 'field list' thrown in /home/asdfasdf/public_html/adsfadsf/rb.php on line 265
how can use total rows divide sum of them average reading?
just use variable:
select @total := count(*), sum(dialogue_score) / @total dialogue_score, sum(consulta_general_score) / @total consulta_general_score, sum(tarea_score) / @total tarea_score, sum(foro_calificacion_score) / @total foro_calificacion_score, sum(foro_respuesta_score) / @total foro_respuesta_score ranking created = :ultima_feha
Comments
Post a Comment