Syntax

Hello, I have the following tables:
Outbound: OutboundID, VisitDate
Inbound: InboundID, ClickDate

How can I select count(OutboundID) and count(InboundID) and group by VisitDate?

Thanks
grogo21Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tigin44Commented:
select date, sumOutbound, sumInbound
from (select convert(datetime, OutboundID, 104) date, count(*) sumOutbound from Outbound group by convert(datetime, OutboundID, 104) a
inner join
(select convert(datetime, InboundID, 104) date, count(*) sumInbound from Inbound group by convert(datetime, InboundID, 104) b on a.date = b.date
0
grogo21Author Commented:
I had to make a few changes to make it work:

select a.date, sumOutbound, sumInbound
from (select convert(VARCHAR(10), ClickDate, 120) date, count(*) sumOutbound from Outbound group by convert(VARCHAR(10), ClickDate, 120)) a
inner join
(select convert(VARCHAR(10), VisitDate, 120) date, count(*) sumInbound from Inbound group by convert(VARCHAR(10), VisitDate, 120)) b on a.date = b.date

However, no records are returned by the query.  The first select from Outbound returns the following records:
2008-10-29      4
2008-10-30      15
2008-11-02      7
2008-11-03      5

The inbound table does not currently have any records.  How can I still make the query you wrote display the records returned from Outbound table and coalesce the inbound count with zero?

Thanks
0
tigin44Commented:
just change the join type to left join.. thats all
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.