Solved

How to join multiple tables with aggregated outout.

Posted on 2012-03-28
3
159 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
[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
3 Comments
 
LVL 40

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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

751 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