Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7428149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:41:54+00:00 2026-05-29T08:41:54+00:00

I am trying to create a report and there are five fields in the

  • 0

I am trying to create a report and there are five fields in the table defining race. To clean up the report I am trying to create a column in the report that has its data create based off of those. To clarify let me give an example.

Current Fields:

RaceAfroAmer, RaceAmerIndian, Race Caucasion, Race Hispanic, RaceOriental

Each of these fields populates with a 1 or a 0

On the report we need a race column that populates based on the values of those fields, i.e.

Race

If the value of any of those 5 fields equals 1 then the value equals that field name (if RaceAfroAmer = 1 then the race column for that row populates with RaceAfroAmer if not it checks the next field, etc, etc).

Will this require creating a new table that the Race field is auto populated and then we pull the race value from that table? Can it be done directly with SSRS programming?

To clarify this further I am inserting below my full original query for the report, in essence all I am trying to do is take this exact query and add a single race column.

WITH HR_CTE (seq, EmployeeId, Name, JobTitle, EffectiveDate, SocSecNbr, State, DateOfBirth, DateHired, SalaryType, CpnyId)
AS
(SELECT ROW_NUMBER() OVER(PARTITION BY E.[EmployeeId] ORDER BY J.EffectiveDate DESC) AS seq,
E.EmployeeID, E.Name, J.JobTitle, J.EffectiveDate, E.SocSecNbr, E.State, E.DateOfBirth, E.DateHired, S.SalaryType, E.CpnyId
FROM XHR_Employee E
JOIN XHR_JobHistory J
    ON E.[EmployeeId] = J.[EmpId]
JOIN XHR_SalaryHist S
    ON E.[EmployeeId] = S.[EmpId])

SELECT EmployeeID, Name, JobTitle, EffectiveDate, SocSecNbr, State, DateOfBirth, DateHired, SalaryType, CpnyId
FROM HR_CTE
WHERE seq = 1
AND (CpnyID IN (@CpnyID))
AND (JobTitle IN (@JobTitle))
AND (SalaryType IN (@SalaryType))
ORDER BY Name

When I change this to include the case statement and Race fields I get an error in syntax near the keyword FROM

WITH HR_CTE (seq, EmployeeId, Name, JobTitle, EffectiveDate, SocSecNbr, State, DateOfBirth, DateHired, SalaryType, CpnyId, RaceAfroAmer, RaceAmerIndian, RaceCaucasian, RaceHispanic, RaceOriental, RaceOther01, RaceOther02)
AS
(SELECT ROW_NUMBER() OVER(PARTITION BY E.[EmployeeId] ORDER BY J.EffectiveDate DESC) AS seq,
E.EmployeeID, E.Name, JobTitle, J.EffectiveDate, E.SocSecNbr, E.State, E.DateOfBirth, E.DateHired, S.SalaryType, E.CpnyId, E.RaceAfroAmer, E.RaceAmerIndian, E.RaceCaucasian, E.RaceHispanic, E.RaceOriental, E.RaceOther01, E.RaceOther02
FROM XHR_Employee E
JOIN XHR_JobHistory J
    ON E.[EmployeeId] = J.[EmpId]
JOIN XHR_SalaryHist S
    ON E.[EmployeeId] = S.[EmpId])

SELECT EmployeeID, Name, JobTitle, EffectiveDate, SocSecNbr, State, DateOfBirth, DateHired, SalaryType, CpnyId, 
CASE
    WHEN RaceAfroAmer = 1 THEN 'Black/African American'
    WHEN RaceAmerIndian = 1 THEN 'American Indian/Alaska Native'
    WHEN RaceCaucasian = 1 THEN 'White'
    WHEN RaceHispanic = 1 THEN 'Hispanic/Latino'
    WHEN RaceOriental = 1 THEN 'Asian'
    WHEN RaceOther01 = 1 THEN 'Native Hawaii/Pacific Islander'
    WHEN RaceOther02 = 1 THEN 'Two Or More Races'
END AS Race,
FROM HR_CTE
WHERE seq = 1
ORDER BY Name

WORKING CODE:

(I took the AS Race out of the bottom of the CASE statement and added the ‘Race’= to the end of the select statement.

WITH HR_CTE (seq, EmployeeId, Name, JobTitle, EffectiveDate, SocSecNbr, State, DateOfBirth, DateHired, SalaryType, CpnyId, RaceAfroAmer, RaceAmerIndian, RaceCaucasian, RaceHispanic, RaceOriental, RaceOther01, RaceOther02)
AS
(SELECT ROW_NUMBER() OVER(PARTITION BY E.[EmployeeId] ORDER BY J.EffectiveDate DESC) AS seq,
E.EmployeeID, E.Name, JobTitle, J.EffectiveDate, E.SocSecNbr, E.State, E.DateOfBirth, E.DateHired, S.SalaryType, E.CpnyId, E.RaceAfroAmer, E.RaceAmerIndian, E.RaceCaucasian, E.RaceHispanic, E.RaceOriental, E.RaceOther01, E.RaceOther02
FROM XHR_Employee E
JOIN XHR_JobHistory J
    ON E.[EmployeeId] = J.[EmpId]
JOIN XHR_SalaryHist S
    ON E.[EmployeeId] = S.[EmpId])

SELECT EmployeeID, Name, JobTitle, EffectiveDate, SocSecNbr, State, DateOfBirth, DateHired, SalaryType, CpnyId, 'Race'=
CASE
    WHEN RaceAfroAmer = 1 THEN 'Black/African American'
    WHEN RaceAmerIndian = 1 THEN 'American Indian/Alaska Native'
    WHEN RaceCaucasian = 1 THEN 'White'
    WHEN RaceHispanic = 1 THEN 'Hispanic/Latino'
    WHEN RaceOriental = 1 THEN 'Asian'
    WHEN RaceOther01 = 1 THEN 'Native Hawaii/Pacific Islander'
    WHEN RaceOther02 = 1 THEN 'Two Or More Races'
END
FROM HR_CTE
WHERE seq = 1
ORDER BY Name
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:41:55+00:00Added an answer on May 29, 2026 at 8:41 am

    The simplest way to do this would be with a case clause in the query:

    select ...
           case
               when RaceAfroAmer = 1 then 'RaceAfroAmer'
               when RaceAmerIndian = 1 then 'RaceAmerIndian'
               when RaceCaucasion = 1 then 'RaceCaucasion'
               when RaceHispanic = 1 then 'RaceHispanic'
               when RaceOriental = 1 then 'RaceOriental'
           end as RaceDescription,
           ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a Crystal Report that reads data from an access table.
I am trying to create a report that has a summary for each group.
I'm trying to create a report of some data. The data has be grouped
I am trying to create a report in SSRS2000 that will query an ORACLE
i am trying to create a report from a row of data with about
I'm trying to create a report that displays for each months of the year
I am trying to build a 2008 SSRS report so that it displays table
I'm trying to create a report in Oracle ApEx that displays a list of
I am trying to create a table with two groups in a BIRT report.
I am trying to find a way to create a report in BIRT that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.