Jorhat JMC sp_Display_batch_students_attendance_percentage_report update

 USE [JMC6]

GO

/****** Object:  StoredProcedure [dbo].[sp_Display_batch_students_attendance_percentage_report]    Script Date: 06-06-2025 16:18:39 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER procedure [dbo].[sp_Display_batch_students_attendance_percentage_report]

@batch_id uniqueidentifier,

@class_from_date date,

@class_upto_date date

as

begin


UPDATE dbo.class SET class_start_time = ISNULL((SELECT MIN(adtLog) FROM class_faculty_view WHERE (class_id = dbo.class.class_id)), dbo.class.class_end_time) WHERE (dbo.class.class_id = dbo.class.class_id)


DECLARE 

@from_date datetime,

@upto_date datetime

set @from_date = @class_from_date

set @upto_date = DATEADD(DAY,1,@class_upto_date)

set @upto_date = DATEADD(SECOND,-1,@upto_date)


  SELECT id

      ,enroll_id

      ,roll_no

      ,enroll_name

      ,department_id

      ,department_name

      ,batch_id

      ,batch_name

      ,[session_id]

      ,session_name

      ,class_of_department_id

      ,class_of_department_name AS class_subject_or_department

  ,(SELECT COUNT(class_id) AS Expr1 FROM dbo.periodic_report_view WHERE (class_of_date BETWEEN @from_date AND @upto_date) AND (uid = dbo.enrollment_of_class_view.id) AND (class_subject_or_department = dbo.enrollment_of_class_view.class_of_department_name)) AS total_number_of_class

  ,(SELECT COUNT(class_id) AS Expr1 FROM dbo.periodic_report_view WHERE (class_of_date BETWEEN @from_date AND @upto_date) AND (uid = dbo.enrollment_of_class_view.id) AND (class_subject_or_department = dbo.enrollment_of_class_view.class_of_department_name) AND (class_status = 'P')) AS total_number_of_present

  ,(SELECT COUNT(class_id) AS Expr1 FROM dbo.periodic_report_view WHERE (class_of_date BETWEEN @from_date AND @upto_date) AND (uid = dbo.enrollment_of_class_view.id) AND (class_subject_or_department = dbo.enrollment_of_class_view.class_of_department_name) AND (class_status = 'A')) AS total_number_of_absent   

  FROM dbo.enrollment_of_class_view

  WHERE batch_id = @batch_id

  AND ((SELECT COUNT(class_id) AS Expr1 FROM dbo.periodic_report_view WHERE (class_of_date BETWEEN @from_date AND @upto_date) AND (uid = dbo.enrollment_of_class_view.id) AND (class_subject_or_department = dbo.enrollment_of_class_view.class_of_department_name)) > 0)


  

End


Comments

Popular posts from this blog

Full Stack Web Development

Reading Substring value from string excel data in c#

Nodemon (automatically restarting the Node.js server)