Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

Modifying SQL query

$
0
0

Hi,

Please find my query below:

SELECT T2.STATUS
              ,COUNT(*) CNT
        FROM (
              SELECT T1.ID, MAX(T1.STATUS_ID) STATUS_ID
              FROM TABLE1 T1
              WHERE  TRUNC(T1.START_DT) >= TO_DATE(RegisteredDateFrom,'dd/MM/yyyy')
              AND TRUNC(T1.START_DT) <= TO_DATE(RegisteredDateTo,'dd/MM/yyyy')
              AND (T1.STATUS IN ('100', '700','300'))
              GROUP BY T1.ID
              ) Result1
        LEFT JOIN TABLE2 T2 ON (Result1.STATUS_ID = T2.STATUS_ID)
        GROUP BY T2.STATUS

This query returns me few rows along with the count for the specific time period.

I want to remove this date filter and provide this Start_DT as a slicer to the end user in Power Pivot. Also CNT should be the calculated based on the START_DT selection from the slicer.

Anybody help me to modify the query? I am not the query expert.

Thanks,

SS


Viewing all articles
Browse latest Browse all 12963

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>