Saturday, February 25, 2012

add from seperate tables

Hi There
How do i add 2 summaries (ie counts) from 2 seperate tables ?
ThanksCan you give an example of what you're trying to do?
"Tango" wrote:
> Hi There
> How do i add 2 summaries (ie counts) from 2 seperate tables ?
> Thanks|||Thanks for your interest George.
table1 has a group with a count of dates summary & table 2 on same report
has a group with a count of a field (happens to be a date field as well)
id like to add a field which is the sum of both & grouped by date
todd
"George Friend" wrote:
> Can you give an example of what you're trying to do?
> "Tango" wrote:
> > Hi There
> > How do i add 2 summaries (ie counts) from 2 seperate tables ?
> > Thanks|||Sounds like:
select
dt,
sum(myValue)
from
(
select
dt,
count(x) as myValue
from
table1
UNION ALL
select
dt,
count(y)
from
table2
) as combinedTable
group by
dt
This takes the output from each and concatenates them together (basically, a
0-cost operation), then summarizes accross them.
"Tango" wrote:
> Thanks for your interest George.
> table1 has a group with a count of dates summary & table 2 on same report
> has a group with a count of a field (happens to be a date field as well)
> id like to add a field which is the sum of both & grouped by date
> todd
>
> "George Friend" wrote:
> > Can you give an example of what you're trying to do?
> >
> > "Tango" wrote:
> >
> > > Hi There
> > > How do i add 2 summaries (ie counts) from 2 seperate tables ?
> > > Thanks

No comments:

Post a Comment