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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:44:16+00:00 2026-05-21T08:44:16+00:00

I am getting the wrong value on gfee and netpay. SELECT s.id, s.name, c.name

  • 0

I am getting the wrong value on gfee and netpay.

SELECT s.id, s.name, c.name AS course_name,
s.open_bal AS open_balance, sum(i.amount) AS gross_fee,
sum(i.discount) AS discount, sum(i.amount) - sum(i.discount) AS net_payable,
SUM(r.reg_fee+r.tut_fee+r.other_fee) AS net_recieved,
(sum(i.amount) - sum(i.discount)) - SUM(r.reg_fee+r.tut_fee+r.other_fee) AS balance_due
FROM subscribers s
INNER JOIN courses c on c.id = s.course_id
LEFT JOIN invoices i on i.student_id = s.id
LEFT JOIN recipts r on r.student_id = s.id
GROUP BY s.id;

Why is this happening?

  • 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-05-21T08:44:17+00:00Added an answer on May 21, 2026 at 8:44 am
    SELECT s.id
         , s.name
         , c.name AS course_name
         , s.open_bal AS open_balance
         , igroup.gross_fee
         , igroup.discount
         , igroup.net_payableinvoices
         , rgroup.net_recieved
         , igroup.net_payableinvoices - rgroup.net_recieved
           AS balance_due
    FROM students s
    INNER JOIN courses c
      on c.id = s.course_id
    LEFT JOIN 
      ( SELECT i.student_id
             , SUM(i.amount) AS gross_fee
             , SUM(i.discount) AS discount
             , SUM(i.amount) - sum(i.discount)
               AS net_payableinvoices
        FROM invoices i
        GROUP BY i.student_id
      ) AS igroup
      ON igroup.student_id = s.id
    LEFT JOIN 
      ( SELECT r.student_id
             , SUM(r.reg_fee+r.tut_fee+r.other_fee)
               AS net_recieved
        FROM recipts r 
        GROUP BY r.student_id
      ) AS rgroup
      ON rgroup.student_id = s.id
    ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What am I doing wrong here? I'm not getting the randomNum value displayed when
I must be doing something completely wrong, but the default value isn't getting set
I am getting a Wrong type argument: commandp, (lambda nil (forward-line 5)) here. (global-set-key
I am getting a wrong output when i alert this, it shows '01' <input
I have a jboss web service that is getting the wrong initial context. I
I'm getting a NoSuchMethodError error when running my Java program. What's wrong and how
new Date(05-MAY-09 03.55.50) is any thing wrong with this ? i am getting illegalArgumentException
Hey! Maybe I am getting the idea of a subclass wrong, but I have
I'm trying to create a rails app, but somethings going wrong, I'm getting a
what am I doing wrong here? I keep on getting a compilation error when

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.