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 7762639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:27:30+00:00 2026-06-01T14:27:30+00:00

I have a simple general weighed average computation in my SELECT : SELECT ROUND(SUM((G.UnitsAcademic*GD.Grade))/SUM(G.UnitsAcademic),3)

  • 0

I have a simple general weighed average computation in my SELECT:

SELECT ROUND(SUM((G.UnitsAcademic*GD.Grade))/SUM(G.UnitsAcademic),3) AS 'GWA'
FROM Gradesheet G 
INNER JOIN GradeSheetDetail AS GD 
    ON GD.GradesheetId=G.GradesheetId

However, some students have non-numeric grades (such as “No Exam”) or blank grades. The code above still computes and returns a value.

I would like it to return a blank (” “) when a non-numeric value gets involved in the computation. Is there a way for SQL to do this?

  • 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-01T14:27:32+00:00Added an answer on June 1, 2026 at 2:27 pm

    Try this:

    SELECT 
        CASE 
            WHEN 
                MAX(CASE WHEN GD.Grade = 'No Grade' OR GD.Grade = ' ' THEN 1 ELSE 0 END) = 1 THEN ' '
            ELSE 
                ROUND(SUM((G.UnitsAcademic*GD.Grade))/SUM(G.UnitsAcademic),3)  
        END AS 'GWA'  
    FROM Gradesheet G  
    INNER JOIN GradeSheetDetail AS GD  
          ON GD.GradesheetId = G.GradesheetId 
    

    First, you need to check if there is at least one non-numeric field, if ‘yes’ then return blank, else calculate aggregate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple class that contains some general information about the current web
I have simple SSIS package which reads data from flat file and insert into
I have simple SSIS package where I import data from flat file into SQL
I have a simple, general question regarding a real small issue that bothers me:
I am looking for some general feedback here. I have a very simple application
I have a pretty simple general programming problem, yet I can't quite get the
In general, is it a best practice to have simple POJO Java classes implement
This is a general how does DataBind work questions... I have a simple page
I have a very general question and have prepared a simple test case. When
I have a general question about WPF performance. We have a relatively simple forms

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.