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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:24:42+00:00 2026-05-11T12:24:42+00:00

Basic need is if a record has an Attribute of Urgent, then the attributevalue

  • 0

Basic need is if a record has an Attribute of ‘Urgent’, then the attributevalue should be displayed in the Urgent column. If the record has an attribute value of ‘closed’, then the attributevalue must be displayed in the ‘Closed’ column.

I have a query below. My problem is that among the results I am getting back, there are two records with the same RequesterID (one with a valid value in ‘Urgent’ column and one with a value in ‘Closed’ colum) My problem is that I need these two particular records to be displayed as one record.

Any ideas?

SELECT DISTINCT     r.RequesterID,    sr.ModifiedDate,    p.FirstName + ' ' + p.LastName AS RequesterName,    CASE      WHEN sa.Attribute = 'Urgent' THEN sa.AttributeValue      ELSE NULL    END AS Urgent,    CASE      WHEN sa.Attribute = 'Closed' THEN sa.AttributeValue       ELSE NULL    END AS Closed FROM    Requester AS r     INNER JOIN SubRequester AS sr       ON r.RequesterID = sr.RequesterID    INNER JOIN SubRequesterAttribute AS sa      ON sr.SubRequesterID = sa.SubRequesterID    CROSS JOIN Personnel AS p WHERE       (r.UserID = p.ContractorID      OR r.UserID = p.EmployeeID)    AND       (sa.Attribute IN ('Urgent', 'Closed')) GROUP BY r.RequesterID, sr.ModifiedDate, p.FirstName, p.LastName,     sa.Attribute, sa.AttributeValue 
  • 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. 2026-05-11T12:24:43+00:00Added an answer on May 11, 2026 at 12:24 pm

    You will need to join to your sub requester attribute table to the query twice. One with the attribute of Urgent and one with the attribute of Close.

    You will need to LEFT join to these for the instances where they may be null and then reference each of the tables in your SELECT to show the relevent attribute.

    I also wouldn’t reccomend the cross join. You should perform your ‘OR’ join on the personnel table in the FROM clause rather than doing a cross join and filtering in the WHERE clause.

    EDIT: Sorry, my first response was a bit rushed. Have now had a chance to look further. Due to the sub requester and the sub requester attribute both being duplicates you need to split them both up into a subquery. Also, your modified date could be different for both values. So i’ve doubled that up. This is completely untested, and by no means the ‘optimum’ solution. It’s quite tricky to write the query without the actual database to check against. Hopefully it will explain what I meant though.

    SELECT     r.RequesterID,     p.FirstName + ' ' + p.LastName AS RequesterName,     sra1.ModifiedDate as UrgentModifiedDate,     sra1.AttributeValue as Urgent,     sra2.ModifiedDate as ClosedModifiedDate,     sra2.AttributeValue as Closed FROM     Personnel AS p INNER JOIN     Requester AS r  ON (     r.UserID = p.ContractorID OR     r.UserID = p.EmployeeID ) LEFT OUTER JOIN (     SELECT         sr1.RequesterID,         sr1.ModifiedDate,         sa1.Attribute,         sa1.AttributeValue     FROM         SubRequester AS sr1     INNER JOIN         SubRequesterAttribute AS sa1     ON         sr1.SubRequesterID = sa1.SubRequesterID     AND         sa1.Attribute = 'Urgent' ) sra1 ON     sra1.RequesterID = r.RequesterID LEFT OUTER JOIN (     SELECT         sr2.RequesterID,         sr2.ModifiedDate,         sa2.Attribute,         sa2.AttributeValue     FROM         SubRequester AS sr2     INNER JOIN         SubRequesterAttribute AS sa2     ON         sr2.SubRequesterID = sa2.SubRequesterID     AND         sa2.Attribute = 'Closed' ) sra1 ON     sra2.RequesterID = r.RequesterID 

    SECOND EDIT: My last edit was that there were multiple SubRequesters as well as multiple Attribute, from your last comment you want to show all SubRequesters and the two relevent attributes? You can achieve this as follows.

    SELECT     r.RequesterID,     p.FirstName + ' ' + p.LastName AS RequesterName,     sr.ModifiedDate,     sa1.AttributeValue as Urgent,     sa2.AttributeValue as Closed FROM     Personnel AS p INNER JOIN     Requester AS r  ON (     r.UserID = p.ContractorID OR     r.UserID = p.EmployeeID ) INNER JOI N     SubRequester as sr ON     sr.RequesterID = r.RequesterID LEFT OUTER JOIN     SubRequesterAttribute AS sa1 ON     sa1.SubRequesterID = sr.SubRequesterID AND     sa1.Attribute = 'Urgent' LEFT OUTER JOIN     SubRequesterAttribute AS sa2 ON     sa2.SubRequesterID = sr.SubRequesterID AND     sa2.Attribute = 'Closed' 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 124k
  • Answers 124k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You have mostly answered your own question when you listed… May 12, 2026 at 1:15 am
  • Editorial Team
    Editorial Team added an answer That is indeed a fun problem. You can't serialize the… May 12, 2026 at 1:15 am
  • Editorial Team
    Editorial Team added an answer That variable isn't uninitialized, it's just undeclared. Declaring variables in… May 12, 2026 at 1:15 am

Related Questions

This is a very basic question. I'm just on my mission to learn ASP.NET
Here is the situation. This small company I'm working with wants to have a
I want to take the results of a where clause on a list and
OK, I've been looking into this a few days and am not particularly sure

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.