Solved

SUM and COUNT

Posted on 2011-03-02
2
322 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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

623 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