Solved

How to join multiple tables with aggregated outout.

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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 …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

679 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