Need to write a query which combines two select statements
Posted on 2014-04-28
My requirement is here, please have a look.
Select TOP 30 SubSystemName, SUM(SQS_Amt) …. WHERE Provider_Type = ‘Hospital’ group by Subsystemname ORDER BY SUM (SQS_AMT)
We need to do something similar for physicians, but it needs to based on the Top 30 Objecting Systems
The logic would be Select SubSystemName, SUM(SQS_AMT) … WHERE PROVIDER_TYPE = ‘Physician’ and SubSystemName in (Select TOP 30 SubSystemName, SUM(SQS_Amt) …. WHERE Provider_Type = ‘Hospital’ … ORDER BY SUM (SQS_AMT)
Basically – I want to identify the Top Objecting Systems by summing $ and descending, and then I want to find the related physicians. Can you try to write that logic?
I am trying to write the logic for this, can anyone help me out