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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:49:26+00:00 2026-06-12T01:49:26+00:00

I have a troublesome SQL query that I’m trying to make using Entrinsik’s Informer.

  • 0

I have a troublesome SQL query that I’m trying to make using
Entrinsik’s Informer. I want Informer to perform a calculation on my
result to make a percentage using javascript. However, Informer lacks
the ability to access data down columns (i.e. my total for the
percentage) so I need my SQL query to generate this for me. The result
currently looks like this:

refund_code    refund_amount    month_group
-----------    -------------    -----------
ref1               10           january
ref2               20           january
ref3               30           january
ref1               40           february
ref2               50           february
ref3               60           february

What I would like is something like this:

refund_code    refund_amount    month_group    month_total  
-----------    -------------    -----------    -----------  
ref1               10           january                 60  
ref2               20           january                 60  
ref3               30           january                 60  
ref1               40           february               150  
ref2               50           february               150  
ref3               60           february               150  

My query is as follows:

SELECT mr.month_group,
    bd.transaction_code AS refund_code,
    SUM(bd.extended) AS refund_amount
FROM   billing_details AS bd
    LEFT JOIN monthly_ranges AS mr
        ON ( bd.entry_date BETWEEN mr.start_date AND mr.end_date )
WHERE  bd.transaction_code IN ( 'REFPRI', 'REFSEC', 'REFPT', 'REFREQPRI' )
    AND bd.entry_date >= '2012-01-05'
GROUP BY mr.month_group, bd.transaction_code
ORDER BY mr.month_group, bd.transaction_code

And a second query to produce a table of totals per month looks like this:

SELECT mr.month_group,
    SUM(bd.extended) AS refund_amount
FROM   billing_details AS bd
    LEFT JOIN monthly_ranges AS mr
        ON ( bd.entry_date BETWEEN mr.start_date AND mr.end_date )
WHERE  bd.transaction_code IN ( 'REFPRI', 'REFSEC', 'REFPT', 'REFREQPRI' )
    AND bd.entry_date >= '2012-01-05'
GROUP BY mr.month_group
ORDER BY mr.month_group

So is there any way to combine the two?

  • 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-12T01:49:27+00:00Added an answer on June 12, 2026 at 1:49 am

    You technically could literally join the two as subqueries.

    i.e.

    SELECT m.refund_code, m.refund_amount, m.month_group, t.month_total
     FROM (your refund query above) m
     JOIN (your total query above) t
       ON m.month_group = t.month_group
    

    Just make sure you rename ‘refund_amount’ in your ‘total query’ to ‘month_total’ or something similar.

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

Sidebar

Related Questions

I have some troublesome form in my django app. Problem is that it doesn't
I have a linq query that is passed into NHibernate which Linq2NHibernate will parse
So I have some code that is being somewhat troublesome to rewrite: def func_A():
i have the following code that adds data to unordered lists. The troublesome code
I have to make an university project that involves a client/server architecture. There should
I have a long string that I want to strip off the end. I
I have a troublesome query to write. I'm currently writing some nasty for loops
I have a troublesome MySQL query as follows: SELECT camera_id, ((avg(low_price) + avg(high_price)) /
Have a painfully simple blog Post creator, and I'm trying to check if the
have a nice day. I got problem when trying to create an image from

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.