doramail05
asked on
Gridview data is missing but stored procedure is showing
Having a gridview does not produce the record as showing below :
1)
select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'A+' AND p.intakename = 'December 2011'
= produces 185
2)
Select * from StudentModulePeriod WHERE id=185
3)
select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'A+' AND p.intakename = 'December 2011'
= produces 30-01-2001
above query generates record,
but in gridview is not showing this record with the long stored procedure in code attached
1)
select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'A+' AND p.intakename = 'December 2011'
= produces 185
2)
Select * from StudentModulePeriod WHERE id=185
3)
select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'A+' AND p.intakename = 'December 2011'
= produces 30-01-2001
above query generates record,
but in gridview is not showing this record with the long stored procedure in code attached
store procedure
---------------
USE [iDash5]
GO
/****** Object: StoredProcedure [dbo].[spViewStudentTimetableByMonth] Script Date: 06/15/2011 16:05:55 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[spViewStudentTimetableByMonth]
@onmonth int,
@intake varchar(100)
--
AS
;with CTE as (
select l.lessonno as lessonno,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusID,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDateClassRoom
from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L01'
UNION
select l.lessonno as lessonno,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusID,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDateClassRoom
from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L02'
UNION
select l.lessonno as lessonno,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusID,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDateClassRoom
from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L03'
UNION
select l.lessonno as lessonno,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusID,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDateClassRoom
from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L04'
UNION
select l.lessonno as lessonno,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusID,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDateClassRoom
from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L05'
UNION
select l.lessonno as lessonno,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusID,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDateClassRoom
from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L06'
UNION
select l.lessonno as lessonno,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusID,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDateClassRoom
from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L07'
UNION
select l.lessonno as lessonno,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusID,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDateClassRoom
from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L08'
UNION
select l.lessonno as lessonno,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusID,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDateClassRoom
from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09'
UNION
select l.lessonno as lessonno,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusID,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDateClassRoom
from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L09'
UNION
select l.lessonno as lessonno,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusID,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDateClassRoom
from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L10'
UNION
select l.lessonno as lessonno,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusID,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDateClassRoom
from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L11'
UNION
select l.lessonno as lessonno,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusID,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDateClassRoom
from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L12'
UNION
select l.lessonno as lessonno,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9ID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusID,
(select smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusID,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M1' AND p.intakename = @intake
) as M1DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M2' AND p.intakename = @intake
) as M2DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M3' AND p.intakename = @intake
) as M3DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M4' AND p.intakename = @intake
) as M4DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M5' AND p.intakename = @intake
) as M5DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M6' AND p.intakename = @intake
) as M6DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M7' AND p.intakename = @intake
) as M7DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M8' AND p.intakename = @intake
) as M8DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9Date,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'M9' AND p.intakename = @intake
) as M9DateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'A+' AND p.intakename = @intake
) as AplusDateClassRoom,
(select smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDate,
(select smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = @onmonth AND
l.lessonno = 'L13' AND m.modulename = 'N+' AND p.intakename = @intake
) as NplusDateClassRoom
from Lesson l),
CTE2 as (select *,ROW_NUMBER() over (PARTITION BY lessonno order by M1ID desc) rn from CTE)
select * from CTE2 where rn = 1
aspx
----
if (dRow.AplusDate == DateTime.MinValue || dRow.AplusDate == SqlDateTime.Null || e.Row.Cells[10].Text == "01/01/0001")
{
e.Row.Cells[10].Text = String.Empty;
}
else if (dRow.AplusDate != DateTime.MinValue || dRow.AplusDate != SqlDateTime.Null || e.Row.Cells[10].Text != "01/01/0001")
{
DataSet ds = StudentTimetable.getStudentModulePeriod_ByID(dRow.AplusID);
e.Row.Cells[10].Text = dRow.AplusDate.ToString("dd/MM/yyyy");
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["classroom"] != DBNull.Value)
{
Label lbl = new Label();
lbl.Text = ds.Tables[0].Rows[0]["classroom"].ToString();
lbl.ForeColor = System.Drawing.Color.Blue;
e.Row.Cells[10].Text = e.Row.Cells[10].Text + "- " + lbl.Text;
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["BufferDay"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[10].Text += " - BD";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["EvaluationTest"]) == true)
{
e.Row.Cells[10].Text += " - ET";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["PracticalTest"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[10].Text += " - PT";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["FinalTest"]) == true)
{
e.Row.Cells[10].Text += " - FT";
}
}
}
ASKER
here they are
aspx
-----
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/mpCMS.master" AutoEventWireup="true" CodeFile="AssignStudentClassroom.aspx.cs" Inherits="CMS_AssignStudentClassroom" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
<style type="text/css">
.style5
{
background-color: #E4E4E4;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<div style="width:900px">
<div id="pagetitle">
<asp:Label ID="lblpagetitle" Text="Manage Student Timetable" runat="server" />
</div>
<asp:UpdatePanel ID="udpStudentTimetable" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
<table style="width: 600px;" cellpadding="3" cellspacing="0">
<tr>
<td width="150px" bgcolor="white" colspan="6">
<asp:Label ID="lblpagemessage" runat="server" CssClass="normalfont" />
</td>
</tr>
<tr>
<td class="style5" width="150px">
<asp:Label ID="lblintaketitle" runat="server" CssClass="normalfont" Text="Intake" />
</td>
<td class="style5" width="10px">
:</td>
<td class="style5">
<asp:DropDownList ID="ddlintake" runat="server" AutoPostBack="true" DataTextField="IntakeName" DataValueField="ID" onselectedindexchanged="ddlintake_SelectedIndexChanged" />
</td>
<td class="style5">
<asp:Label ID="lblmonth" runat="server" CssClass="normalfont" Text="Month" />
</td>
<td class="style5">
:</td>
<td class="style5">
<asp:DropDownList ID="ddlmonth" runat="server" AutoPostBack="true" onselectedindexchanged="ddlmonth_SelectedIndexChanged" />
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td colspan="4">
</td>
</tr>
<tr>
<td class="style5">
<asp:Label ID="lblDateTitle" runat="server" CssClass="normalfont" Text="Date " />
</td>
<td class="style5">
:
</td>
<td colspan="4" class="style5">
<asp:TextBox ID="txtDate" runat="server" />
<asp:CalendarExtender ID="txtDate_CalendarExtender" runat="server" Format="dd/MM/yyyy" TargetControlID="txtDate">
</asp:CalendarExtender>
</td>
</tr>
<tr>
<td class="style5">
<asp:Label ID="lblClassRoomTitle" runat="server" CssClass="normalfont" Text="Classroom " />
</td>
<td class="style5">
:</td>
<td colspan="4" class="style5">
<asp:DropDownList ID="ddlclassroom" runat="server" DataTextField="ClassRoom" DataValueField="ID" />
</td>
</tr>
<tr>
<td class="style5">
<asp:Label ID="lblTrainer" runat="server" CssClass="normalfont" Text="Trainer " />
</td>
<td class="style5">
:</td>
<td class="style5" colspan="4">
<asp:DropDownList ID="ddltrainer" runat="server" DataTextField="TrainerName" DataValueField="ID" />
</td>
</tr>
<tr>
<td class="style5">
<asp:Label ID="lblETestTitle" runat="server" CssClass="normalfont" Text="Evaluation Test " />
</td>
<td class="style5">
:</td>
<td colspan="4" class="style5">
<asp:CheckBox ID="cbETest" runat="server" />
</td>
</tr>
<tr>
<td class="style5">
<asp:Label ID="lblFTestTitle" runat="server" CssClass="normalfont" Text="Final Test" />
</td>
<td class="style5">
:</td>
<td colspan="4" class="style5">
<asp:CheckBox ID="cbFTest" runat="server" />
</td>
</tr>
<tr>
<td class="style5">
<asp:Label ID="lblPTestTitle" runat="server" CssClass="normalfont" Text="Practical Test " />
</td>
<td class="style5">
:</td>
<td colspan="4" class="style5">
<asp:CheckBox ID="cbPTest0" runat="server" />
</td>
</tr>
<tr>
<td class="style5">
<asp:Label ID="lblBDayTitle" runat="server" CssClass="normalfont" Text="Buffer Day" />
</td>
<td class="style5">
:</td>
<td colspan="4" class="style5">
<asp:CheckBox ID="cbBufferDay" runat="server" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblApplyTo" runat="server" CssClass="normalfont" Text="Apply To : " />
</td>
<td>
</td>
<td colspan="4">
</td>
</tr>
<tr>
<td class="style5">
<asp:Label ID="lblLesson0" runat="server" CssClass="normalfont" Text="Lesson" />
</td>
<td class="style5">
:</td>
<td colspan="4" class="style5">
<asp:DropDownList ID="ddllesson" runat="server" DataTextField="LessonNo" DataValueField="ID" />
</td>
</tr>
<tr>
<td class="style5">
<asp:Label ID="lblModule" runat="server" CssClass="normalfont" Text="Module " />
</td>
<td class="style5">
:</td>
<td colspan="4" class="style5">
<asp:DropDownList ID="ddlmodule" runat="server" DataTextField="ModuleName" DataValueField="ID" />
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td colspan="4">
<asp:LinkButton ID="lblApplyToTimetable0" runat="server" CssClass="shortbutton" Text="Apply" onclick="lblApplyToTimetable0_Click" />
</td>
</tr>
</table>
<asp:Label ID="lblemptyrecord01" runat="server" CssClass="normalfont" Text="No record(s) found." />
<br />
<asp:GridView ID="gvStudentTimeTable" runat="server" Width="1000px" GridLines="None" CssClass="datatableNormal"
AutoGenerateColumns="false"
AlternatingRowStyle-CssClass="datatableHighlight" BorderColor="#cccccc" BorderWidth="1" onrowdatabound="gvStudentTimeTable_RowDataBound"
>
<Columns>
<asp:BoundField HeaderText="Lesson" DataField="LessonNo" HeaderStyle-Width="10px" HeaderStyle-HorizontalAlign="Left" ItemStyle-CssClass="datatableitem" HeaderStyle-CssClass="gridheaderstudentatt" />
<asp:BoundField HeaderText="M1" DataField="M1Date" dataformatstring="{0:dd/MM/yyyy}" HeaderStyle-Width="290px" HeaderStyle-HorizontalAlign="Left" ItemStyle-CssClass="datatableitem" HeaderStyle-CssClass="gridheaderstudentatt" />
<asp:BoundField HeaderText="M2" DataField="M2Date" dataformatstring="{0:dd/MM/yyyy}" HeaderStyle-Width="290px" HeaderStyle-HorizontalAlign="Left" ItemStyle-CssClass="datatableitem" HeaderStyle-CssClass="gridheaderstudentatt" />
<asp:BoundField HeaderText="M3" DataField="M3Date" dataformatstring="{0:dd/MM/yyyy}" HeaderStyle-Width="290px" HeaderStyle-HorizontalAlign="Left" ItemStyle-CssClass="datatableitem" HeaderStyle-CssClass="gridheaderstudentatt" />
<asp:BoundField HeaderText="M4" DataField="M4Date" dataformatstring="{0:dd/MM/yyyy}" HeaderStyle-Width="290px" HeaderStyle-HorizontalAlign="Left" ItemStyle-CssClass="datatableitem" HeaderStyle-CssClass="gridheaderstudentatt" />
<asp:BoundField HeaderText="M5" DataField="M5Date" dataformatstring="{0:dd/MM/yyyy}" HeaderStyle-Width="290px" HeaderStyle-HorizontalAlign="Left" ItemStyle-CssClass="datatableitem" HeaderStyle-CssClass="gridheaderstudentatt" />
<asp:BoundField HeaderText="M6" DataField="M6Date" dataformatstring="{0:dd/MM/yyyy}" HeaderStyle-Width="290px" HeaderStyle-HorizontalAlign="Left" ItemStyle-CssClass="datatableitem" HeaderStyle-CssClass="gridheaderstudentatt" />
<asp:BoundField HeaderText="M7" DataField="M7Date" dataformatstring="{0:dd/MM/yyyy}" HeaderStyle-Width="290px" HeaderStyle-HorizontalAlign="Left" ItemStyle-CssClass="datatableitem" HeaderStyle-CssClass="gridheaderstudentatt" />
<asp:BoundField HeaderText="M8" DataField="M8Date" dataformatstring="{0:dd/MM/yyyy}" HeaderStyle-Width="290px" HeaderStyle-HorizontalAlign="Left" ItemStyle-CssClass="datatableitem" HeaderStyle-CssClass="gridheaderstudentatt" />
<asp:BoundField HeaderText="M9" DataField="M9Date" dataformatstring="{0:dd/MM/yyyy}" HeaderStyle-Width="290px" HeaderStyle-HorizontalAlign="Left" ItemStyle-CssClass="datatableitem" HeaderStyle-CssClass="gridheaderstudentatt" />
<asp:BoundField HeaderText="A+" DataField="AplusDate" dataformatstring="{0:dd/MM/yyyy}" HeaderStyle-Width="290px" HeaderStyle-HorizontalAlign="Left" ItemStyle-CssClass="datatableitem" HeaderStyle-CssClass="gridheaderstudentatt" />
<asp:BoundField HeaderText="N+" DataField="NplusDate" dataformatstring="{0:dd/MM/yyyy}" HeaderStyle-Width="290px" HeaderStyle-HorizontalAlign="Left" ItemStyle-CssClass="datatableitem" HeaderStyle-CssClass="gridheaderstudentatt" />
</Columns>
</asp:GridView>
<asp:Panel ID="pnlSubmitButton" runat="server">
<div style="margin-left: 1400px">
<asp:LinkButton ID="lbSubmit" runat="server" CssClass="shortbutton" Text="Submit" />
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Content>
code-behind
-----------
protected void Page_Load(object sender, EventArgs e)
{
lblemptyrecord01.Visible = false;
lblpagemessage.Visible = false;
// txtDate_CalendarExtender.
if (!Page.IsPostBack)
{
bindIntake();
bindDDLMonth();
bindClassroom();
bindTrainer();
bindLesson();
bindModule();
bindGrid();
}
DateTime moment = new DateTime(DateTime.Now.Year, Convert.ToInt32(ddlmonth.SelectedValue), 1);
txtDate_CalendarExtender.SelectedDate = moment;
}
void bindGrid()
{
if (!String.IsNullOrEmpty(ddlmonth.SelectedValue) && !String.IsNullOrEmpty(ddlintake.SelectedValue))
{
List<StudentTimetable> list_studenttimetable = new List<StudentTimetable>();
list_studenttimetable = StudentTimetable.getStudentTimeTableBy_Intake_Month_SPAll(Convert.ToInt32(ddlmonth.SelectedValue), ddlintake.SelectedItem.Text);
if (list_studenttimetable.Count > 0)
{
gvStudentTimeTable.DataSource = list_studenttimetable;
gvStudentTimeTable.DataBind();
udpStudentTimetable.Update();
lblemptyrecord01.Visible = false;
}
else
{
lblemptyrecord01.Visible = true;
}
}
}
void bindIntake()
{
List<Period> list_p = new List<Period>();
list_p = Period.getAllIntakeName();
if (list_p.Count > 0)
{
ddlintake.DataSource = list_p;
ddlintake.DataBind();
}
}
void bindModule()
{
List<Module> list_m = new List<Module>();
list_m = Module.getModule();
if (list_m.Count > 0)
{
ddlmodule.DataSource = list_m;
ddlmodule.DataBind();
}
}
void bindLesson()
{
List<Lesson> list_l = new List<Lesson>();
list_l = Lesson.getAllLesson();
if (list_l.Count > 0)
{
ddllesson.DataSource = list_l;
ddllesson.DataBind();
}
}
void bindClassroom()
{
List<Classroom> list_cr = new List<Classroom>();
list_cr = Classroom.getAllClassroom();
if (list_cr.Count > 0)
{
ddlclassroom.DataSource = list_cr;
ddlclassroom.DataBind();
}
}
void bindTrainer()
{
List<Trainer> list_tr = new List<Trainer>();
list_tr = Trainer.getAllTrainerID();
if (list_tr.Count > 0)
{
ddltrainer.DataSource = list_tr;
ddltrainer.DataBind();
}
}
void bindDDLMonth()
{
ddlmonth.Items.Clear();
ddlmonth.Items.Add(new ListItem("January", "1"));
ddlmonth.Items.Add(new ListItem("February", "2"));
ddlmonth.Items.Add(new ListItem("March", "3"));
ddlmonth.Items.Add(new ListItem("April", "4"));
ddlmonth.Items.Add(new ListItem("May", "5"));
ddlmonth.Items.Add(new ListItem("June", "6"));
ddlmonth.Items.Add(new ListItem("July", "7"));
ddlmonth.Items.Add(new ListItem("August", "8"));
ddlmonth.Items.Add(new ListItem("September", "9"));
ddlmonth.Items.Add(new ListItem("October", "10"));
ddlmonth.Items.Add(new ListItem("November", "11"));
ddlmonth.Items.Add(new ListItem("December", "12"));
ddlmonth.DataBind();
}
protected void ddlintake_SelectedIndexChanged(object sender, EventArgs e)
{
bindGrid();
}
protected void ddlmonth_SelectedIndexChanged(object sender, EventArgs e)
{
bindGrid();
}
protected void gvStudentTimeTable_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
//for (int i = 0; i < gvStudentTimeTable.Columns.Count; i++)
//{
gvStudentTimeTable.Columns[0].HeaderStyle.Width = 90;
//}
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
gvStudentTimeTable.Columns[0].ItemStyle.Width = 30;
SqlDateTime sqldatetime = SqlDateTime.Null;
StudentTimetable dRow = (StudentTimetable)e.Row.DataItem;
if (dRow.M1Date == DateTime.MinValue || dRow.M1Date == SqlDateTime.Null || e.Row.Cells[1].Text == "01/01/0001")
{
e.Row.Cells[1].Text = String.Empty;
}
else if (dRow.M1Date != DateTime.MinValue || dRow.M1Date != SqlDateTime.Null || e.Row.Cells[1].Text != "01/01/0001")
{
DataSet ds = StudentTimetable.getStudentModulePeriod_ByID(dRow.M1ID);
e.Row.Cells[1].Text = dRow.M1Date.ToString("dd/MM/yyyy");
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["classroom"] != DBNull.Value)
{
Label lbl = new Label();
lbl.Text = ds.Tables[0].Rows[0]["classroom"].ToString();
lbl.ForeColor = System.Drawing.Color.Blue;
e.Row.Cells[1].Text = e.Row.Cells[1].Text + "- " + lbl.Text;
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["BufferDay"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[1].Text += " - BD";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["EvaluationTest"]) == true)
{
e.Row.Cells[1].Text += " - ET";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["PracticalTest"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[1].Text += " - PT";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["FinalTest"]) == true)
{
e.Row.Cells[1].Text += " - FT";
}
}
}
if (dRow.M2Date == DateTime.MinValue || dRow.M2Date == SqlDateTime.Null || e.Row.Cells[2].Text == "01/01/0001")
{
e.Row.Cells[2].Text = String.Empty;
}
else if (dRow.M2Date != DateTime.MinValue || dRow.M2Date != SqlDateTime.Null || e.Row.Cells[2].Text != "01/01/0001")
{
DataSet ds = StudentTimetable.getStudentModulePeriod_ByID(dRow.M2ID);
e.Row.Cells[2].Text = dRow.M2Date.ToString("dd/MM/yyyy");
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["classroom"] != DBNull.Value)
{
Label lbl = new Label();
lbl.Text = ds.Tables[0].Rows[0]["classroom"].ToString();
lbl.ForeColor = System.Drawing.Color.Blue;
e.Row.Cells[2].Text = e.Row.Cells[2].Text + "- " + lbl.Text;
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["BufferDay"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[2].Text += " - BD";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["EvaluationTest"]) == true)
{
e.Row.Cells[2].Text += " - ET";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["PracticalTest"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[2].Text += " - PT";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["FinalTest"]) == true)
{
e.Row.Cells[2].Text += " - FT";
}
}
}
if (dRow.M3Date == DateTime.MinValue || dRow.M3Date == SqlDateTime.Null || e.Row.Cells[3].Text == "01/01/0001")
{
e.Row.Cells[3].Text = String.Empty;
}
else if (dRow.M3Date != DateTime.MinValue || dRow.M3Date != SqlDateTime.Null || e.Row.Cells[3].Text != "01/01/0001")
{
DataSet ds = StudentTimetable.getStudentModulePeriod_ByID(dRow.M3ID);
e.Row.Cells[3].Text = dRow.M3Date.ToString("dd/MM/yyyy");
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["classroom"] != DBNull.Value)
{
Label lbl = new Label();
lbl.Text = ds.Tables[0].Rows[0]["classroom"].ToString();
lbl.ForeColor = System.Drawing.Color.Blue;
e.Row.Cells[3].Text = e.Row.Cells[3].Text + "- " + lbl.Text;
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["BufferDay"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[3].Text += " - BD";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["EvaluationTest"]) == true)
{
e.Row.Cells[3].Text += " - ET";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["PracticalTest"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[3].Text += " - PT";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["FinalTest"]) == true)
{
e.Row.Cells[3].Text += " - FT";
}
}
}
if (dRow.M4Date == DateTime.MinValue || dRow.M4Date == SqlDateTime.Null || e.Row.Cells[4].Text == "01/01/0001")
{
e.Row.Cells[4].Text = String.Empty;
}
else if (dRow.M4Date != DateTime.MinValue || dRow.M4Date != SqlDateTime.Null || e.Row.Cells[4].Text != "01/01/0001")
{
DataSet ds = StudentTimetable.getStudentModulePeriod_ByID(dRow.M4ID);
e.Row.Cells[4].Text = dRow.M4Date.ToString("dd/MM/yyyy");
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["classroom"] != DBNull.Value)
{
Label lbl = new Label();
lbl.Text = ds.Tables[0].Rows[0]["classroom"].ToString();
lbl.ForeColor = System.Drawing.Color.Blue;
e.Row.Cells[4].Text = e.Row.Cells[3].Text + "- " + lbl.Text;
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["BufferDay"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[4].Text += " - BD";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["EvaluationTest"]) == true)
{
e.Row.Cells[4].Text += " - ET";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["PracticalTest"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[4].Text += " - PT";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["FinalTest"]) == true)
{
e.Row.Cells[4].Text += " - FT";
}
}
}
if (dRow.M5Date == DateTime.MinValue || dRow.M5Date == SqlDateTime.Null || e.Row.Cells[5].Text == "01/01/0001")
{
e.Row.Cells[5].Text = String.Empty;
}
else if (dRow.M5Date != DateTime.MinValue || dRow.M5Date != SqlDateTime.Null || e.Row.Cells[5].Text != "01/01/0001")
{
DataSet ds = StudentTimetable.getStudentModulePeriod_ByID(dRow.M5ID);
e.Row.Cells[5].Text = dRow.M5Date.ToString("dd/MM/yyyy");
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["classroom"] != DBNull.Value)
{
Label lbl = new Label();
lbl.Text = ds.Tables[0].Rows[0]["classroom"].ToString();
lbl.ForeColor = System.Drawing.Color.Blue;
e.Row.Cells[5].Text = e.Row.Cells[5].Text + "- " + lbl.Text;
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["BufferDay"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[5].Text += " - BD";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["EvaluationTest"]) == true)
{
e.Row.Cells[5].Text += " - ET";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["PracticalTest"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[5].Text += " - PT";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["FinalTest"]) == true)
{
e.Row.Cells[5].Text += " - FT";
}
}
}
if (dRow.M6Date == DateTime.MinValue || dRow.M6Date == SqlDateTime.Null || e.Row.Cells[6].Text == "01/01/0001")
{
e.Row.Cells[6].Text = String.Empty;
}
else if (dRow.M6Date != DateTime.MinValue || dRow.M6Date != SqlDateTime.Null || e.Row.Cells[6].Text != "01/01/0001")
{
DataSet ds = StudentTimetable.getStudentModulePeriod_ByID(dRow.M6ID);
e.Row.Cells[6].Text = dRow.M6Date.ToString("dd/MM/yyyy");
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["classroom"] != DBNull.Value)
{
Label lbl = new Label();
lbl.Text = ds.Tables[0].Rows[0]["classroom"].ToString();
lbl.ForeColor = System.Drawing.Color.Blue;
e.Row.Cells[6].Text = e.Row.Cells[6].Text + "- " + lbl.Text;
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["BufferDay"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[6].Text += " - BD";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["EvaluationTest"]) == true)
{
e.Row.Cells[6].Text += " - ET";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["PracticalTest"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[6].Text += " - PT";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["FinalTest"]) == true)
{
e.Row.Cells[6].Text += " - FT";
}
}
}
if (dRow.M7Date == DateTime.MinValue || dRow.M7Date == SqlDateTime.Null || e.Row.Cells[7].Text == "01/01/0001")
{
e.Row.Cells[7].Text = String.Empty;
}
else if (dRow.M7Date != DateTime.MinValue || dRow.M7Date != SqlDateTime.Null || e.Row.Cells[7].Text != "01/01/0001")
{
DataSet ds = StudentTimetable.getStudentModulePeriod_ByID(dRow.M7ID);
e.Row.Cells[7].Text = dRow.M7Date.ToString("dd/MM/yyyy");
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["classroom"] != DBNull.Value)
{
Label lbl = new Label();
lbl.Text = ds.Tables[0].Rows[0]["classroom"].ToString();
lbl.ForeColor = System.Drawing.Color.Blue;
e.Row.Cells[7].Text = e.Row.Cells[7].Text + "- " + lbl.Text;
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["BufferDay"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[7].Text += " - BD";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["EvaluationTest"]) == true)
{
e.Row.Cells[7].Text += " - ET";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["PracticalTest"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[7].Text += " - PT";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["FinalTest"]) == true)
{
e.Row.Cells[7].Text += " - FT";
}
}
}
if (dRow.M8Date == DateTime.MinValue || dRow.M8Date == SqlDateTime.Null || e.Row.Cells[8].Text == "01/01/0001")
{
e.Row.Cells[8].Text = String.Empty;
}
else if (dRow.M8Date != DateTime.MinValue || dRow.M8Date != SqlDateTime.Null || e.Row.Cells[8].Text != "01/01/0001")
{
DataSet ds = StudentTimetable.getStudentModulePeriod_ByID(dRow.M8ID);
e.Row.Cells[8].Text = dRow.M8Date.ToString("dd/MM/yyyy");
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["classroom"] != DBNull.Value)
{
Label lbl = new Label();
lbl.Text = ds.Tables[0].Rows[0]["classroom"].ToString();
lbl.ForeColor = System.Drawing.Color.Blue;
e.Row.Cells[8].Text = e.Row.Cells[8].Text + "- " + lbl.Text;
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["BufferDay"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[8].Text += " - BD";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["EvaluationTest"]) == true)
{
e.Row.Cells[8].Text += " - ET";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["PracticalTest"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[8].Text += " - PT";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["FinalTest"]) == true)
{
e.Row.Cells[8].Text += " - FT";
}
}
}
if (dRow.M9Date == DateTime.MinValue || dRow.M9Date == SqlDateTime.Null || e.Row.Cells[9].Text == "01/01/0001")
{
e.Row.Cells[9].Text = String.Empty;
}
else if (dRow.M9Date != DateTime.MinValue || dRow.M9Date != SqlDateTime.Null || e.Row.Cells[9].Text != "01/01/0001")
{
DataSet ds = StudentTimetable.getStudentModulePeriod_ByID(dRow.M9ID);
e.Row.Cells[9].Text = dRow.M9Date.ToString("dd/MM/yyyy");
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["classroom"] != DBNull.Value)
{
Label lbl = new Label();
lbl.Text = ds.Tables[0].Rows[0]["classroom"].ToString();
lbl.ForeColor = System.Drawing.Color.Blue;
e.Row.Cells[9].Text = e.Row.Cells[9].Text + "- " + lbl.Text;
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["BufferDay"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[9].Text += " - BD";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["EvaluationTest"]) == true)
{
e.Row.Cells[9].Text += " - ET";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["PracticalTest"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[9].Text += " - PT";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["FinalTest"]) == true)
{
e.Row.Cells[9].Text += " - FT";
}
}
}
if (dRow.AplusDate == DateTime.MinValue || dRow.AplusDate == SqlDateTime.Null || e.Row.Cells[10].Text == "01/01/0001")
{
e.Row.Cells[10].Text = String.Empty;
}
else if (dRow.AplusDate != DateTime.MinValue || dRow.AplusDate != SqlDateTime.Null || e.Row.Cells[10].Text != "01/01/0001")
{
DataSet ds = StudentTimetable.getStudentModulePeriod_ByID(dRow.AplusID);
e.Row.Cells[10].Text = dRow.AplusDate.ToString("dd/MM/yyyy");
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["classroom"] != DBNull.Value)
{
Label lbl = new Label();
lbl.Text = ds.Tables[0].Rows[0]["classroom"].ToString();
lbl.ForeColor = System.Drawing.Color.Blue;
e.Row.Cells[10].Text = e.Row.Cells[10].Text + "- " + lbl.Text;
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["BufferDay"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[10].Text += " - BD";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["EvaluationTest"]) == true)
{
e.Row.Cells[10].Text += " - ET";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["PracticalTest"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[10].Text += " - PT";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["FinalTest"]) == true)
{
e.Row.Cells[10].Text += " - FT";
}
}
}
if (dRow.NplusDate == DateTime.MinValue || dRow.NplusDate == SqlDateTime.Null || e.Row.Cells[11].Text == "01/01/0001")
{
e.Row.Cells[11].Text = String.Empty;
}
else if (dRow.NplusDate != DateTime.MinValue || dRow.NplusDate != SqlDateTime.Null || e.Row.Cells[11].Text != "01/01/0001")
{
DataSet ds = StudentTimetable.getStudentModulePeriod_ByID(dRow.NplusID);
e.Row.Cells[11].Text = dRow.NplusDate.ToString("dd/MM/yyyy");
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["classroom"] != DBNull.Value)
{
Label lbl = new Label();
lbl.Text = ds.Tables[0].Rows[0]["classroom"].ToString();
lbl.ForeColor = System.Drawing.Color.Blue;
e.Row.Cells[11].Text = e.Row.Cells[11].Text + "- " + lbl.Text;
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["BufferDay"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[11].Text += " - BD";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["EvaluationTest"]) == true)
{
e.Row.Cells[11].Text += " - ET";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["PracticalTest"]) == true)
{
// e.Row.Cells[1].Text = e.Row.Cells[1].Text + " BD";
e.Row.Cells[11].Text += " - PT";
}
if (Convert.ToBoolean(ds.Tables[0].Rows[0]["FinalTest"]) == true)
{
e.Row.Cells[11].Text += " - FT";
}
}
}
}
}
private bool bBufferDay;
private bool bFinalTest;
private bool bEvaluationTest;
private bool bPracticalTest;
protected void lblApplyToTimetable0_Click(object sender, EventArgs e)
{
if (cbBufferDay.Checked)
{
bBufferDay = true;
}
else
{
bBufferDay = false;
}
if (cbETest.Checked)
{
bEvaluationTest = true;
}
else
{
bEvaluationTest = false;
}
if (cbFTest.Checked)
{
bFinalTest = true;
}
else
{
bFinalTest = false;
}
if (cbPTest0.Checked)
{
bPracticalTest = true;
}
else
{
bPracticalTest = false;
}
string strResult = StudentModulePeriod.InsertStudentModulePeriod(Convert.ToInt64(ddlmodule.SelectedValue), Convert.ToInt64(ddlintake.SelectedValue), Convert.ToInt64(ddllesson.SelectedValue),
Convert.ToInt64(ddltrainer.SelectedValue), Convert.ToDateTime(txtDate.Text), ddlclassroom.SelectedItem.Text, bBufferDay, bFinalTest, bPracticalTest, bEvaluationTest);
if (strResult != "Insert Successful")
{
lblpagemessage.Text = strResult;
lblpagemessage.ForeColor = System.Drawing.Color.Red;
lblpagemessage.Visible = true;
}
if (strResult == "Insert Successful")
{
lblpagemessage.Text = strResult;
lblpagemessage.ForeColor = System.Drawing.Color.Green;
lblpagemessage.Visible = true;
}
bindGrid();
}
Line 269: if (list_studenttimetable.Cou nt >Â 0)
Does "list_studenttimetable" ever have Count >Â 0? maybe the Databinding is not even being called at all. Set a breakpoint there and eexecute the applicaiton with F5
Does "list_studenttimetable" ever have Count >Â 0? maybe the Databinding is not even being called at all. Set a breakpoint there and eexecute the applicaiton with F5
ASKER
when use
EXEC spViewStudentTimetableByMo nth 1, 'December 2011'
it retrives M1, and M2 Date, (12-1-2011, etc)
BUT for the record (30-1-2011) which is in A+ and L12,
it does not show in sp Results and also debug mode
and when use the portion of taking only L12,
it retrieves 30-1-2011
EXEC spViewStudentTimetableByMo
it retrives M1, and M2 Date, (12-1-2011, etc)
BUT for the record (30-1-2011) which is in A+ and L12,
it does not show in sp Results and also debug mode
and when use the portion of taking only L12,
it retrieves 30-1-2011
select l.lessonno as lessonno,
(select TOP 1 smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M1' AND p.intakename = 'December 2011'
) as M1ID,
(select TOP 1 smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M2' AND p.intakename = 'December 2011'
) as M2ID,
(select TOP 1 smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M3' AND p.intakename = 'December 2011'
) as M3ID,
(select TOP 1 smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M4' AND p.intakename = 'December 2011'
) as M4ID,
(select TOP 1 smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M5' AND p.intakename = 'December 2011'
) as M5ID,
(select TOP 1 smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M6' AND p.intakename = 'December 2011'
) as M6ID,
(select TOP 1 smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M7' AND p.intakename = 'December 2011'
) as M7ID,
(select TOP 1 smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M8' AND p.intakename = 'December 2011'
) as M8ID,
(select TOP 1 smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M9' AND p.intakename = 'December 2011'
) as M9ID,
(select TOP 1 smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'A+' AND p.intakename = 'December 2011'
) as AplusID,
(select TOP 1 smp.id from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'N+' AND p.intakename = 'December 2011'
) as NplusID,
(select TOP 1 smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M1' AND p.intakename = 'December 2011'
) as M1Date,
(select TOP 1 smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M1' AND p.intakename = 'December 2011'
) as M1DateClassRoom,
(select TOP 1 smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M2' AND p.intakename = 'December 2011'
) as M2Date,
(select TOP 1 smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M2' AND p.intakename = 'December 2011'
) as M2DateClassRoom,
(select TOP 1 smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M3' AND p.intakename = 'December 2011'
) as M3Date,
(select TOP 1 smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M3' AND p.intakename = 'December 2011'
) as M3DateClassRoom,
(select TOP 1 smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M4' AND p.intakename = 'December 2011'
) as M4Date,
(select TOP 1 smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M4' AND p.intakename = 'December 2011'
) as M4DateClassRoom,
(select TOP 1 smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M5' AND p.intakename = 'December 2011'
) as M5Date,
(select TOP 1 smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M5' AND p.intakename = 'December 2011'
) as M5DateClassRoom,
(select TOP 1 smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M6' AND p.intakename = 'December 2011'
) as M6Date,
(select TOP 1 smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M6' AND p.intakename = 'December 2011'
) as M6DateClassRoom,
(select TOP 1 smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M7' AND p.intakename = 'December 2011'
) as M7Date,
(select TOP 1 smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M7' AND p.intakename = 'December 2011'
) as M7DateClassRoom,
(select TOP 1 smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M8' AND p.intakename = 'December 2011'
) as M8Date,
(select TOP 1 smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M8' AND p.intakename = 'December 2011'
) as M8DateClassRoom,
(select TOP 1 smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M9' AND p.intakename = 'December 2011'
) as M9Date,
(select TOP 1 smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'M9' AND p.intakename = 'December 2011'
) as M9DateClassRoom,
(select TOP 1 smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'A+' AND p.intakename = 'December 2011'
) as AplusDate,
(select TOP 1 smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'A+' AND p.intakename = 'December 2011'
) as AplusDateClassRoom,
(select TOP 1 smp.starttime from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'N+' AND p.intakename = 'December 2011'
) as NplusDate,
(select TOP 1 smp.classroom from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12' AND m.modulename = 'N+' AND p.intakename = 'December 2011'
) as NplusDateClassRoom
from StudentModulePeriod smp
INNER JOIN Lesson l ON smp.lid = l.id
INNER JOIN Module m ON smp.mid = m.id
INNER JOIN Period p ON smp.pid = p.id
INNER JOIN Trainer tr ON smp.trid = tr.id
WHERE DATEPART(month, smp.onmonth) = 1 AND
l.lessonno = 'L12'
ASKER
Added
select * CTE2 cc
Â
and the data appear,
problem found that it has duplicated row in L1 and L2.
select * CTE2 cc
Â
and the data appear,
problem found that it has duplicated row in L1 and L2.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
only workaround
Could the issue be in the .NET code binding the GridView to your results? Â
Maybe post your .NET code too (if that is what you're using). Â Are you calling DataBind() method of the GridView?