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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:20:51+00:00 2026-06-11T08:20:51+00:00

The first part of the code creates a table based on SUM statements: SELECT

  • 0

The first part of the code creates a table based on SUM statements:

SELECT varday, COUNT(*) AS Vol,
SUM(FOPS_REHAB) AS FOPS_REHAB,
SUM(FOPS_RECOVERY) AS FOPS_RECOVERY
  FROM table
  WHERE PROCESSING_DATE > '31/aug/2012' and rownumber =1 
GROUP BY varday
ORDER BY varday

However, I have two other code parts that I want to combine into the code above but they have an extra ‘where’ criteria.

So these are the two sum statements I want to combine to the table above;

select SUM(Current_Balance_Amount)as rec_bal, varday
 into #temp
  from table
   where fops_recovery = 1 and  PROCESSING_DATE > '31/aug/2012' and rownumber =1 
group by varday
ORDER BY varday


select SUM(Current_Balance_Amount)as reh_bal, varday
 into #temp
  from table
   where fops_rehab = 1 and  PROCESSING_DATE > '31/aug/2012' and rownumber =1 
group by varday
ORDER BY varday

So reh_bal and rec_bal are in one table with the first table which contains FOPS_REHAB and FOPS_RECOVERY. I’m having problems because they have an extra clause (where fops recovery = 1 or fops rehab = 1).

  • 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-11T08:20:52+00:00Added an answer on June 11, 2026 at 8:20 am

    I believe all 3 queries can be combined into one, try this:

    select  varday, 
            COUNT(*) AS Vol,
            SUM(FOPS_REHAB) AS FOPS_REHAB,
            SUM(FOPS_RECOVERY) AS FOPS_RECOVERY,
            SUM(CASE WHEN fops_recovery = 1 THEN Current_Balance_Amount ELSE 0 END) rec_bal,
            SUM(CASE WHEN fops_rehab = 0 THEN Current_Balance_Amount ELSE 0 END) reh_bal
    where   PROCESSING_DATE > '31/aug/2012' and rownumber =1 
    group   by varday
    ORDER   BY varday
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the first part of my controller code: public class ControlMController : Controller
20120315021529.000[-8:PST] to get the first part I was able by using below C# code.
The first part of this question is actually a request for confirmation based on
I am using Entity Framework 4.1 code first. I had a table in the
I have the following code but it keeps presenting errors. The first part of
The first part of the query before not in runs and gives me a
The first part of this question is now its own, here: Analyzing Text for
I've read that by standard first part of e-mail is case sensitive, however I've
I'm moving my first stpes in iOS development. I have followed the first part
Ok, I got the first part of my question answered, so here's the second

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.