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

  • SEARCH
  • Home
  • 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 7982471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:41:20+00:00 2026-06-04T10:41:20+00:00

I am trying to use the With Rollup function to determine the TOTAL number

  • 0

I am trying to use the With Rollup function to determine the TOTAL number of rows returned in my query and use that number to determine the percentage of each result in relation to the TOTAL rows in the query.
Here is my code:

Declare @startDate DateTime, @endDate DateTime;
Set @startDate = '01/01/01'
Set @endDate = '01/01/13'

SELECT
  isnull(EducationType.EducationTypeDesc, 'UNKNOWN') as 'Education Type Description',
  COUNT(isnull(EducationType.EducationTypeDesc, 'UNKNOWN')) as 'Record Count'
FROM
  EducationType LEFT OUTER JOIN
  Education ON EducationType.EducationTypeID = Education.EducationTypeID LEFT OUTER JOIN
  Volunteer ON Volunteer.PartyID = Education.PartyID
WHERE     (Volunteer.SwornDate BETWEEN @startDate AND @endDate)
GROUP BY isnull(EducationType.EducationTypeDesc, 'UNKNOWN')
WITH ROLLUP 
ORDER BY isnull(EducationType.EducationTypeDesc, 'UNKNOWN')

I get the total count in the record in which EducationType.EducationTypeDesc shows NULL but cannot figure out how to calculate the percentage in the query.

Thanks
Andy

  • 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-04T10:41:21+00:00Added an answer on June 4, 2026 at 10:41 am

    Load the row count from an un-grouped version of your query, and the calculate the percentage:

    Declare @startDate DateTime, @endDate DateTime;
    Set @startDate = '01/01/01';
    Set @endDate = '01/01/13';
    DECLARE @rows MONEY;
    
    SELECT @rows=COUNT(1)
    FROM
      EducationType LEFT OUTER JOIN
      Education ON EducationType.EducationTypeID = Education.EducationTypeID LEFT OUTER JOIN
      Volunteer ON Volunteer.PartyID = Education.PartyID
    WHERE     (Volunteer.SwornDate BETWEEN @startDate AND @endDate);
    
    SELECT
      isnull(EducationType.EducationTypeDesc, 'UNKNOWN') as 'Education Type Description',
      COUNT(isnull(EducationType.EducationTypeDesc, 'UNKNOWN')) as 'Record Count',
      COUNT(isnull(EducationType.EducationTypeDesc, 'UNKNOWN')) / @rows * 100 as 'Percent'
    FROM
      EducationType LEFT OUTER JOIN
      Education ON EducationType.EducationTypeID = Education.EducationTypeID LEFT OUTER JOIN
      Volunteer ON Volunteer.PartyID = Education.PartyID
    WHERE     (Volunteer.SwornDate BETWEEN @startDate AND @endDate)
    GROUP BY isnull(EducationType.EducationTypeDesc, 'UNKNOWN')
    WITH ROLLUP 
    ORDER BY isnull(EducationType.EducationTypeDesc, 'UNKNOWN');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying use the edit_post_link() function to contain an image. All of
I am trying use a javascript function while passing php variables in it. For
I am trying use a javascript function while passing php variables in it. For
I'm trying to use group by with rollup clause within sql server 2005 but
I have a regex that I'm trying use to validate against strings. Trying to
I have a 3rd party DLL that I am trying to use in a
I am trying use the jQuery table sorter plugin for a table that is
I am trying use the onClick() function in an activity for an android app.
I am trying use the mysql connector in c++ in ubuntu. It appears that
I revieving the following error when trying use mysql_real_escape() function Fatal error: Call to

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.