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

  • Home
  • SEARCH
  • 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 6689939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:34:41+00:00 2026-05-26T05:34:41+00:00

SELECT ERI.ATTACK_CASE_ID, LRM.REF_VALUE AS ATTACK_CASE_STATUS, WDR.RESTRICTION_NAME, LL.USER_LABEL AS ***RESTRICTION_STATUS***, WSRI.RESTRICTION_DATE, CASE NVL(ERI.IS_PRIMARY, 0) WHEN

  • 0
SELECT 
      ERI.ATTACK_CASE_ID, 
      LRM.REF_VALUE AS ATTACK_CASE_STATUS,
      WDR.RESTRICTION_NAME, 
    LL.USER_LABEL AS ***RESTRICTION_STATUS***,
     WSRI.RESTRICTION_DATE,
       CASE NVL(ERI.IS_PRIMARY, 0) WHEN 0 THEN 'No' ELSE CASE ERI.IS_PRIMARY WHEN 1 THEN 'Yes' ELSE 'No' END END AS PRIMARY
FROM ALERT A 
 LEFT OUTER JOIN ENTITY_RESTRICTION_INFO ERI ON A.ALERT_KEY=ERI.ENTITY_KEY
 LEFT OUTER JOIN LK_REFERENCE_MAPPING LRM ON LRM.REF_KEY= TO_CHAR(ERI.ATTACK_CASE_STATUS)
 LEFT OUTER JOIN LK_REFERENCE_CATEGORY LRG ON LRM.LK_REFERENCE_CATEGORY_ID = LRG.ID 
AND  LRG.CATEGORY_CODE = 'DD' 
AND LRG.SUB_CATEGORY_CODE='ATTACK_STATUS_ID_NAME'   
 LEFT OUTER JOIN WNORKOM_DD_RESTRICTION WDR ON ERI.RESTRICTION_ID=WDR.RESTRICTION_ID 
 LEFT OUTER JOIN WNORKOM_SAR_RESTRICT_INFO WSRI ON WSRI.RESTRICTION_ID=ERI.RESTRICTION_ID
 *LEFT OUTER JOIN LK_LOOKUPS LL ON LL.CODE=**WSRI.RESTRICTION_STATUS***
WHERE A.ALERT_KEY=121234 
AND ERI.ATTACK_CASE_ID='PP-123-0980'
AND LL.TYPE=9502

The above query returns me all the records when there is some value in WSRI.RESTRICTION_STATUS

However, it returns NO RECORDS when WSRI.RESTRICTION_STATUS = NULL.
What can I add/change in above query so that LL.USER_LABEL = ‘Unknown’ when WSRI.RESTRICTION_STATUS = NULL. For your information, there is no value ‘Unknown’ in LK_LOOKUPS table. This is something I want to return as an independent string when WSRI.RESTRICTION_STATUS = NULL. Adding a record to LK_LOOKUPS table with LL.CODE=NULL and LL.USER_LABEL=’Unknown’ can mess up things so please help me passing it independently in the query.

Thanks in advance.

  • 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-26T05:34:42+00:00Added an answer on May 26, 2026 at 5:34 am

    It sounds you simply need to move the criteria LL.Type = 9502 into the Left Join and use Coalesce in the Select clause. Also, since you are applying criteria to a column in the Entity_Restriction_Info table from the Where clause, you have transformed the Left Join to this table into an Inner Join and thus, you might as well use an Inner Join.

    Select Eri.Attack_Case_Id
        , Lrm.Ref_Value As Attack_Case_Status
        , Wdr.Restriction_Name
        , Coalesce(LL.User_Label, 'Unknown') As Restriction_Status
        , Wsri.Restriction_Date
        , Case Nvl(Eri.Is_Primary, 0) 
            When 0 Then 'No' 
            Else Case Eri.Is_Primary 
                    When 1 Then 'Yes' 
                    Else 'No' 
                    End 
            End As Primary
    From Alert As A
        Inner Join Entity_Restriction_Info As Eri 
            On A.Alert_Key=Eri.Entity_Key
        Left Outer Join Lk_Reference_Mapping As Lrm 
            On Lrm.Ref_Key= To_Char(Eri.Attack_Case_Status)
        Left Outer Join Lk_Reference_Category As Lrg 
            On Lrm.Lk_Reference_Category_Id = Lrg.Id
                And  Lrg.Category_Code = 'Dd' 
                And Lrg.Sub_Category_Code='Attack_Status_Id_Name'   
        Left Outer Join Wnorkom_Dd_Restriction As Wdr 
            On Eri.Restriction_Id=Wdr.Restriction_Id 
        Left Outer Join Wnorkom_Sar_Restrict_Info As Wsri 
            On Wsri.Restriction_Id=Eri.Restriction_Id
        Left Outer Join Lk_Lookups As LL
            On LL.Code='Wsri.Restriction_Status'
                And LL.Type=9502
    Where A.Alert_Key=121234 
        And Eri.Attack_Case_Id='Pp-123-0980'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SELECT COUNT(id), AgeRange FROM ( select id, case when age < 0 then 'less
SELECT dteRun, CASE WHEN coalesce(nPriorityCode,0) <= 0 THEN 3 ELSE nPriorityCode END AS nPriorityCode,
SELECT MIN(Measurement), (CASE 'NonDesMin' WHEN len(measurement) = 6 then '0000' ELSE '000' END) as
SELECT DATE(DTM) AS'Dia', ROUND(COUNT(TMP)/4) AS 'Oídio' CASE ROUND(COUNT(TMP)/4)>=6 THEN '20' ROUND(COUNT(TMP)/4)<6 THEN '-10' END
SELECT events.title FROM events ORDER BY events.title DESC I'm getting the proper ordering for
select @result=@input.query('*') for xml raw,type Above statement will generate following alert: Msg 6819, Level
SELECT sum(TotalHoursM) + (TotalHoursT) + (TotalHoursW) + (TotalHoursTH) + (TotalHoursF) AS TOTAL FROM LeaveRequest
SELECT (SELECT IIF(IsNull(sum(b.AmountCharged) - sum(b.AmountPaid)), a.Balance, (sum(b.AmountCharged) - sum(b.AmountPaid))) FROM tblCurrentTransaction AS b WHERE
SELECT AVG(variable) AS Expr1, SUM(variable) AS Expr2 FROM ...... result for AVG is 2,
select convert(varbinary(8), 1) in MS SQL Server produces output : 0x00000001 On assigning the

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.