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 8749679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:44:02+00:00 2026-06-13T12:44:02+00:00

I have one master table with all the IDs to each child table. The

  • 0

I have one master table with all the IDs to each child table. The SQL statement looks like this…

SELECT   Class.Descript
       , Regulation.Descript AS Reg
       , Compgroup.Descript AS Grouping
       , Category.Descript AS Cat
       , Exempt.Descript AS Exempt
       , Reason.Descript AS Reasons
       , COALESCE(ComponentRuleSet.NormalType, ComponentRuleSet.Supertype, '') AS Type
FROM     ComponentRuleSet 
LEFT OUTER JOIN Reason 
   ON ComponentRuleSet.ComponentCategoryID = Reason.ComponentCategoryID 
LEFT OUTER JOIN Class 
   ON ComponentRuleSet.ComponentClassID = Class.ComponentClassID
LEFT OUTER JOIN Regulation
   ON ComponentRuleSet.RegulationID = Regulation.RegulationID 
LEFT OUTER JOIN Compgroup
   ON ComponentRuleSet.ComplianceGroupID = Compgroup.ComplianceGroupID
LEFT OUTER JOIN Category 
   ON ComponentRuleSet.ComponentCategoryID = Category.ComponentCategoryId
LEFT OUTER JOIN Exempt 
   ON ComponentRuleSet.ExemptID = Exempt.ComponentExemptionID
WHERE (ComponentRuleSet.ComponentID = 38048)

The problem is that there are two fields in the ComponentRuleSet table called NormalType and Supertype. If either of those fields have a value, I need to display it in a column called Type. Yet, if neither have a value I need to display a Blank value in the Type column.
Any ideas?

—EDIT

Is my placement of COALESCE correct in the edited query? It is still returning errors.

–UPDATE

IMPORTANT: The type of both fields are boolean, I need to return the column name of the column that holds a TRUE value, and place that value in the TYPE column.

  • 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-06-13T12:44:04+00:00Added an answer on June 13, 2026 at 12:44 pm

    Seeing your comments, perhaps a CASE expression will work:

    select ...
          , CASE WHEN ComponentRuleSet.NormalType is not null then 'NormalType'
                 WHEN ComponentRuleSet.Supertype  is not null then 'SuperType'
                 ELSE ''
                 end as Type
    

    UPDATE Since boolean values are just 1 for true and 0 for false, try this:

    select ...
          , CASE WHEN ComponentRuleSet.NormalType = 1 then 'NormalType'
                 WHEN ComponentRuleSet.Supertype  = 1 then 'SuperType'
                 ELSE ''
                 end as Type
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one table that looks something like this: id parent_id name 1 0
I have one master page which applies to all pages in this website. On
I have ten master tables and one Transaction table. In my transaction table (it
The setup is simple, a Master table and a linked Child table (one master,
I have USER table(master table) and ONLINE table(refrence table with one to one relationship
I have a database table structured like this (irrelevant fields omitted for brevity): rankings
I have one master report with sub report. in master report display single value
I am working on asp.net using c#. I have one master page with 3
I am working with an ASP.NET MVC application. I have one master page having
I have a one master Page. I want to add 3 Menu items to

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.