mardi 14 février 2017

Random values returned in mysql

i'm having some issues working with mysql, in a particular case, i'm getting random values in a query

  select t.rango AS "Rango de Precios", AVG(comentarios.puntos) as Promedio
from
    comentarios RIGHT JOIN juegos ON(comentarios.id_juego = juegos.id_juegos),
   (select case
       when precio = 0 then 'Gratis'
       when precio > 0 and precio < 300 then 'De 0 a 300'
       when precio > 300 and precio < 600 then 'De 300 a 600'
    else 'Mayor a 600'
       end
       as rango,
       precio
       from juegos) as t  
group by rango

I dont know why, but i'm getting random values from comentarios.id_juegos table, i supose its because a mistake in the query

I hope you can help me!

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire