Ver Mensaje Individual
  #8 (permalink)  
Antiguo 08/11/2013, 09:34
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, 9 meses
Puntos: 774
Respuesta: Problema con Join en Procedimiento

pregunta, porque no haces esto:

Código SQL:
Ver original
  1. ALTER PROCEDURE [dbo].[listarExamenesProfesor]
  2. @Id_Profesor INT
  3. AS
  4. SELECT cu.Nombre AS CURSOS,ex.Nombre AS EXAMEN,ex.FecHora AS FECHA_Y_HORA,
  5. COUNT(r.AlumnoId) AS RINDIERON,
  6. CASE WHEN nota>=7 THEN COUNT(1) END AS aprobaron,
  7. CASE WHEN nota< 7 THEN COUNT(1) END AS reprobaron
  8. FROM CURSO cu LEFT JOIN EXAMEN ex ON cu.IdCurso=ex.CursoId LEFT JOIN RESULTADO r ON ex.IdExamen=r.ExamenId
  9. LEFT JOIN Curso_Alumno cal ON cu.IdCurso=cal.IDCURSO
  10. WHERE cu.ProfId=@Id_Profesor
  11. GROUP BY cu.IdCurso,cu.Nombre,cu.Estado,cu.FecIni,cu.FecFin,cu.ProfId,
  12. ex.IdExamen,ex.Nombre,ex.Descripcion,ex.FecHora,ex.Duracion,ex.CursoId
  13.  
  14. GO
__________________
What does an execution plan say to t-sql query? Go f**k yourself, if you are not happy with me