Solved

How to join multiple tables with aggregated outout.

Posted on 2012-03-28
3
154 Views
Last Modified: 2012-03-29
I am using this command given by one of the experts to get the desired output on the basis of state,district,source.
Here there is only 2 tables.Similarly i want to append the result from other tables say t1 and t2 to this query, joining to be done on same fields.
select state,district,source,
count(
       CASE
         WHEN rfeeddate between '2012-3-1' and '2012-3-31' THEN 1
         ELSE NULL
       END) as cnt,
count(
       CASE
         WHEN rfeeddate<='2012-3-31' THEN 1
         ELSE NULL
       END) as cntTill
from mstchvs where flagr=1 and
group by state,district,source
order by 1,2,3
0
Comment
Question by:searchsanjaysharma
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
lcohan earned 500 total points
ID: 37778093
Did you tried to do that using CTE? I think it should fit your need:

http://msdn.microsoft.com/en-us/library/ms190766(v=sql.90).aspx
0
 

Author Comment

by:searchsanjaysharma
ID: 37779264
I am not able to achieve it.Kindly help with query
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 37785797
ok
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now