Solved

SUM and COUNT

Posted on 2011-03-02
2
320 Views
Last Modified: 2012-05-11
Hi everyone!!!

What is the query to perform a SUM and COUNT in Table A where in Table B there is a column of true and false that will be the condition for the SUM and COUNT function?

Table A has the column name "numbers".  Table B has a column name "flag"  of true and false.  Both tables share the same unique ID of course.

So my goal is to get the SUM and COUNT of the column "numbers" in tableA if FLAG = true in TableB and  if FLAG = false in TableB.

I need the two SUM and COUNT values.

Thanks in advance.
0
Comment
Question by:m3mdicl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 500 total points
ID: 35021721

select  flag, SUM(numbers) Summation, Count(numbers) Number
from table1
inner join table2 on table2.id = table1.id
group by flag
0
 

Author Comment

by:m3mdicl
ID: 35021836
thanks mate. works like a charm.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question