Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8105679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:13:31+00:00 2026-06-06T00:13:31+00:00

I am using following procedure to retrieve total presents and absents by using pivot

  • 0

I am using following procedure to retrieve total presents and absents by using pivot query….i want to SUM of Presents[P] And Absents[A] And then calculate percentage

ALTER PROCEDURE [dbo].[GetAttendence](@Course_Id varchar(30), @Semester varchar(10))

AS
   SELECT DISTINCT Enroll_Number, Course_Id, Semester, Isnull([P],0) 
                                           As Presents, Isnull([A],0) As Absents

    FROM (SELECT Enroll_Number, Course_Id, Semester, Flag from Attendence ) ps
    pivot(Count(Flag) for Flag in ([P],[A])) as pvt 

    WHERE Course_Id = @Course_Id and Semester = @Semester

This is Forula to implement….

Sum = Presents + Absents

Percentage = ((Presents / Sum) * 100)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T00:13:33+00:00Added an answer on June 6, 2026 at 12:13 am

    Try this:

    select Enroll_Number,
           Course_Id,
           Semester,
           P as Presents,
           A as Absents,
           P+A as SumPA,
           1.0*P/(P+A)*100 as Percentage
    from
      (
        select Enroll_Number, Course_Id, Semester, Flag
        from Attendence
        where Course_Id = @Course_Id and 
              Semester = @Semester
      ) ps
    pivot
      (
        count(Flag) for Flag in ([P],[A])
      ) as pvt 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using following storedprocedure set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO Alter PROCEDURE
Im using following procedure in one of my applications ALTER procedure [dbo].[FeeRecordSelect] @GRNo varchar(4),
I am using the following code to connect to an Oracle stored procedure, with
I am using Oracle 10g and I have the following stored procedure: CREATE OR
I was using the following procedure for a while: git fetch origin master git
I'm using FastReport 4.7.31 in Turbo Delphi Pro. The following procedure processes the data
Using the following code in Delphi 2007: procedure TfrmTest.PaintBox1Paint(Sender: TObject); const Rect_Size = 10;
I am using following code: Note that i HAVE TO SEND SQL Query so
What i want to do is the following procedure: Get a frame from the
If, using the following code in a MS SQL Server 2008 stored procedure: DECLARE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.