sql BIT / IAM-1814 - spObtenerInscImportacionMasCals - Seagregacondiciónraraque coincida la

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql BIT / IAM-1814 - spObtenerInscImportacionMasCals - Seagregacondiciónraraque coincida la相关的知识,希望对你有一定的参考价值。


----------------------------INICIO PROCEDIMIENTO ------------------------
IF OBJECT_ID('spObtenerInscImportacionMasCals', 'P') IS NOT NULL
      DROP PROC spObtenerInscImportacionMasCals 
GO

CREATE PROCEDURE [dbo].[spObtenerInscImportacionMasCals]
  @inscripciones     LISTAINSACAD READONLY,
  @sCodigoTemporales VARCHAR(32)
/* --------------------------------------------------------------------------------------------------------------
	FECHA	   |    AUTOR		|	DESCRIPCION
 30/jun./2017  | Luis Bernal	| BIT/IAM-1814 - Se agrega condición para que coincida la OfertaEduc de @inscripciones con la de insReal
--------------------------------------------------------------------------------------------------------------*/
AS
  BEGIN
      SET NOCOUNT ON;

      IF @sCodigoTemporales IS NULL
        SELECT alsparam.sMatricula
               ,al.idAlumno
               ,alsparam.idPlantel
               ,alsparam.iFolioPeriodo
               ,alsparam.idOfEduc
               ,alsparam.idPlanEstudios
               ,alsparam.idAsignatura
               ,alsparam.idGrupo
               ,NULL AS iFolioInscripcionTmp
               ,ins.iFolio AS iFolioInscripcionReal
               ,NULL AS iFolioTrayectoriaTmp
               ,acad.iFolio AS iFolioTrayectoriaReal
               ,CAST(validacion.bExistenCalifs AS BIT) bExistenCalifs
        FROM   @inscripciones alsparam
               LEFT JOIN Cat_Alumnos al
                      ON al.sMatricula = alsparam.sMatricula
                         AND EXISTS(SELECT insPlantel.idAlumno
                                    FROM   Ctrl_Inscripciones insPlantel
                                    WHERE  insPlantel.idAlumno = al.idAlumno
                                           AND insPlantel.idPlantel = alsparam.idPlantel)
               LEFT JOIN ctrl_inscripciones ins
                      ON ins.idPlantel = alsparam.idPlantel
                         AND ins.idAlumno = al.idAlumno
                         AND ins.iFolioPeriodo = alsparam.iFolioPeriodo
               LEFT JOIN Ctrl_TrayectoriaAcademica acad
                      ON acad.iFolioInscripcion = ins.iFolio
                         AND acad.idAsignatura = alsparam.idAsignatura
                         AND acad.idGrupo = alsparam.idGrupo
               OUTER APPLY (SELECT CASE
                                     WHEN EXISTS (SELECT iFolioTrayectoria
                                                  FROM   Ctrl_TrayectoriaAcademicaDet acadet
                                                  WHERE  acad.iFolio IS NOT NULL
                                                         AND acad.iFolio = acadet.iFolioTrayectoria
                                                         AND ( acadet.bHistorica IS NULL
                                                                OR acadet.bHistorica = 0 )) THEN 1
                                     ELSE 0
                                   END AS bExistenCalifs) validacion
        WHERE  ins.iFolio IS NULL
                OR ins.idPlantel = alsparam.idPlantel
      ELSE
        BEGIN
            SELECT alsparam.sMatricula
                   ,COALESCE(insReal.idAlumno, insTmp.idAlumno) AS idAlumno
                   ,alsparam.idPlantel
                   ,alsparam.iFolioPeriodo
                   ,alsparam.idOfEduc
                   ,alsparam.idPlanEstudios
                   ,alsparam.idAsignatura
                   ,alsparam.idGrupo
                   ,insTmp.iFolio AS iFolioInscripcionTmp
                   ,insReal.iFolio AS iFolioInscripcionReal
                   ,acad.iFolio AS iFolioTrayectoriaTmp
                   ,insReal.iFolioTrayReal AS iFolioTrayectoriaReal
                   ,CAST(isnull(validacion.bExistenCalifs, 0) AS BIT) bExistenCalifs
            FROM   @inscripciones alsparam
                   OUTER APPLY (SELECT al.idAlumno
                                       ,ins.iFolio
                                FROM   Cat_Alumnos al
                                       INNER JOIN Ctrl_InscripcionesTmpCalif ins
                                               ON ins.idPlantel = alsparam.idPlantel
                                                  AND ins.idAlumno = al.idAlumno
                                                  AND ins.iFolioPeriodo = alsparam.iFolioPeriodo
                                                  AND al.sMatricula = alsparam.sMatricula
                                                  AND ins.scodigo = @sCodigoTemporales) insTmp
                   OUTER APPLY (SELECT al2.idAlumno
                                       ,insR.iFolio
                                       ,acadR.iFolio AS iFolioTrayReal
                                FROM   Cat_Alumnos al2
                                       INNER JOIN Ctrl_Inscripciones insR
                                               ON insR.idPlantel = alsparam.idPlantel
                                                  AND insR.idAlumno = al2.idAlumno
                                                  AND insR.iFolioPeriodo = alsparam.iFolioPeriodo
												  AND insR.idOfEduc = alsparam.idOfEduc				-- >> BIT/IAM-1814 << --
                                                  AND al2.sMatricula = alsparam.sMatricula
                                       LEFT JOIN Ctrl_TrayectoriaAcademica acadR
                                              ON acadR.iFolioInscripcion = insR.iFolio
                                                 AND acadR.idAsignatura = alsparam.idAsignatura
                                                 AND acadR.idGrupo = alsparam.idGrupo) insReal
                   LEFT JOIN Ctrl_TrayectoriaAcademicaTmpCalif acad
                          ON ( ( insReal.iFolio IS NOT NULL
                                 AND acad.iFolioInscripcionReal = insReal.iFolio )
                                OR ( insTmp.iFolio IS NOT NULL
                                     AND acad.iFolioInscripcion = insTmp.iFolio ) )
                             AND acad.idAsignatura = alsparam.idAsignatura
                             AND acad.idGrupo = alsparam.idGrupo
                             AND acad.scodigo = @sCodigoTemporales
                   OUTER APPLY (SELECT CASE
                                         WHEN EXISTS (SELECT iFolioTrayectoria
                                                      FROM   Ctrl_TrayectoriaAcademicaDet acadet
                                                      WHERE  insReal.iFolioTrayReal IS NOT NULL
                                                             AND insReal.iFolioTrayReal = acadet.iFolioTrayectoria
                                                             AND ( acadet.bHistorica IS NULL
                                                                    OR acadet.bHistorica = 0 )) THEN 1
                                         ELSE 0
                                       END AS bExistenCalifs) validacion
            WHERE  NOT EXISTS (SELECT ins.iFolio
                               FROM   ctrl_inscripciones ins
                               WHERE  ins.idAlumno = insTmp.idAlumno
                                      AND ins.idplantel != alsparam.idPlantel)
        END
  END 

以上是关于sql BIT / IAM-1814 - spObtenerInscImportacionMasCals - Seagregacondiciónraraque coincida la的主要内容,如果未能解决你的问题,请参考以下文章

sql BIT / IAM-1758 - sp_CE_ListarCalificacionesAsigRubSubRubCompletasAlumno - Se adiciona JOIN c

sql BIT / IAM-2081 - sp2CES_ALU_ObtenerInfoInscripVigente - Se agrega para obtener la oferta edu

sql server 2008 r2 sp1 怎么看版本

跪求SQL Server 2008 R2 Standard (64-bit) x64下载地址。

windows server 2003 64 位能不能支持 SQL 2000? 是需要安装SQL sp4的补丁吗? 顺求 2003 64位系统..

windows server 2003 64bit SP2下安装RabbitMQ