Ver Mensaje Individual
  #8 (permalink)  
Antiguo 24/02/2014, 14:44
Avatar de Libras
Libras
Colaborador
 
Fecha de Ingreso: agosto-2006
Ubicación: En la hermosa perla de occidente
Mensajes: 7.412
Antigüedad: 17 años, 8 meses
Puntos: 774
Respuesta: como utilizar un case en una subconsuta

Código SQL:
Ver original
  1. SELECT idnumber,firstname,lastname,
  2. CASE WHEN questionattemptid=74118 THEN fraction END AS nota1,
  3. CASE WHEN questionattemptid=74119 THEN fraction END AS nota2,
  4. CASE WHEN questionattemptid=74120 THEN fraction END AS nota3
  5. FROM
  6. di082_question_attempt_steps
  7. INNER JOIN di082_user ON di082_user.id=di082_question_attempt_steps.userid
  8. WHERE questionattemptid IN
  9. (SELECT id FROM di082_question_attempts WHERE questionid>=74118 AND questionid<=74120) AND fraction IS NOT NULL ORDER BY lastname, firstname

y asi regresa o que quieres???
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me