Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SUM and COUNT

Posted on 2011-03-02
2
Medium Priority
?
326 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

There are some very powerful Dynamic Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a di…
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

719 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