Ver Mensaje Individual
  #9 (permalink)  
Antiguo 24/02/2014, 15:47
felipe12357
 
Fecha de Ingreso: junio-2010
Mensajes: 168
Antigüedad: 13 años, 11 meses
Puntos: 3
Respuesta: como utilizar un case en una subconsuta

Gracias por la ayuda, ya encontre la solucion!:
Código MySQL:
Ver original
  1. select idnumber,firstname,lastname,
  2. MAX (case WHEN (questionattemptid in(select id from di082_question_attempts where questionid=74118 )) then round(fraction) end) as Q1,
  3. MAX (case WHEN (questionattemptid in(select id from di082_question_attempts where questionid=74119 )) then round(fraction) end) as Q2,
  4. MAX (case WHEN (questionattemptid in(select id from di082_question_attempts where questionid=74120 )) then round(fraction) end) as Q3,
  5. from di082_question_attempt_steps inner join di082_user on di082_user.id=di082_question_attempt_steps.userid
  6. where questionattemptid in(select id from di082_question_attempts where questionid>=74118 and questionid<=74147) and fraction is not null
  7. group by di082_user.idnumber,di082_user.firstname, di082_user.lastname
  8. order by lastname, firstname

Gracias

Última edición por gnzsoloyo; 24/02/2014 a las 17:48