Solved

How to join multiple tables with aggregated outout.

Posted on 2012-03-28
3
155 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

In this article I will describe the Backup & Restore 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 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.
A short film showing how OnPage and Connectwise integration works.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

914 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

13 Experts available now in Live!

Get 1:1 Help Now