Quantcast
Viewing all articles
Browse latest Browse all 1418

SSRS Query Help

My query below executes Zero Rows. I need to get these columns;DemoGroupOrder,DemoGroup,DemographicGroup & DemoGrouplabe. How should I write this query, so I get the rows I want.

Thanks for your help

Declare @DemoGroupOrder int,
@ReportDate date,
@DemoCategory varchar (200)

SELECT DISTINCT 'Age' DemographicGroup,
CASE WHEN DATEDIFF(YY, [Date of Birth], @ReportDate) < 25 THEN '<=25'
WHEN DATEDIFF(YY,[Date of Birth],@ReportDate) BETWEEN 25 AND 35 THEN '26-35'
WHEN DATEDIFF(YY,[Date of Birth],@ReportDate) BETWEEN 36 AND 45 THEN '36-45'
WHEN DATEDIFF(YY,[Date of Birth],@ReportDate) > 45 THEN '46+' END AS DemoGroup,

case
WHEN DATEDIFF(YY,[Date of Birth],@ReportDate) < 25 THEN 1
WHEN DATEDIFF(YY,[Date of Birth] ,@ReportDate) BETWEEN 25 AND 35 THEN 2
WHEN DATEDIFF(YY,[Date of Birth],@ReportDate) BETWEEN 36 AND 45 THEN 3
WHEN DATEDIFF(YY,[Date of Birth],@ReportDate) > 45 THEN 4 END AS DemoGroupOrder
INTO #Demographic
FROM BorrowerDim_Staging
UNION
SELECT DISTINCT 'Marital Status',[Marital Status], 1
FROM BorrowerDim_Staging
UNION
SELECT DISTINCT 'Race', Race, 1
FROM BorrowerDim_Staging
UNION
SELECT DISTINCT 'Sex', Sex, 1
FROM BorrowerDim_Staging
SELECT *, DemographicGroup + ' - ' + DemoGroup DemoGrouplabel
FROM #Demographic
WHERE DemographicGroup IN (@DemoCategory)
ORDER BY DemographicGroup, DemoGroupOrder


Viewing all articles
Browse latest Browse all 1418

Trending Articles



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