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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:46:47+00:00 2026-05-26T14:46:47+00:00

CASE WHEN P.NURSING_UNIT is not null THEN P.NURSING_UNIT ELSE ” END NURSING_UNIT ,CASE WHEN

  • 0
CASE WHEN P.NURSING_UNIT is not null THEN P.NURSING_UNIT ELSE '' END NURSING_UNIT
    ,CASE WHEN P.UNIT_CODE is not null THEN P.UNIT_CODE ELSE '' END UNIT_CODE, 
    CASE WHEN M.SIGN_DATE IS NOT NULL THEN 'COMPLETED' ELSE 
    WHEN M.SIGN_DATE IS NULL THEN 'UNCOMPLETED' AS ASSESSMENTS

error: because the sp is not compiling now. getting this error message:
Msg 156, Level 15, State 1, Procedure GET_SCHEDULE_ALL_DETAIL, Line 18
Incorrect syntax near the keyword ‘WHEN’.
Msg 156, Level 15, State 1, Procedure GET_SCHEDULE_ALL_DETAIL, Line 25
Incorrect syntax near the keyword ‘AND’.

    ----

    USE [PRO]
    GO

    /****** Object: StoredProcedure [dbo].[GET_SCHEDULE_ALL_DETAIL] Script Date: 11/02/2011 14:14:50 ******/
    SET ANSI_NULLS ON
    GO

    SET QUOTED_IDENTIFIER ON
    GO


    alter PROC [dbo].[GET_SCHEDULE_ALL_DETAIL]
    @FACILITYKEY varchar(1000),
    @UNITSTR VARCHAR(100),
    @FromDate datetime,
    @ToDate datetime
    AS
    BEGIN

    (SELECT S.FACILITY_KEY, S.PAT_NUMBER, S.A3A_DATE_USER, M.REFERENCE_DATE ,
    RTRIM(P.LAST_NAME) + CASE WHEN RTRIM(P.FIRST_NAME) <> '' THEN ', '
    ELSE ''
    END + RTRIM(P.FIRST_NAME) PATIENT_NAME
    ,CASE WHEN P.NURSING_UNIT is not null THEN P.NURSING_UNIT ELSE '' END NURSING_UNIT
    ,CASE WHEN P.UNIT_CODE is not null THEN P.UNIT_CODE ELSE '' END UNIT_CODE, 
    CASE WHEN M.SIGN_DATE IS NOT NULL THEN 'COMPLETED' ELSE 
    WHEN M.SIGN_DATE IS NULL THEN 'UNCOMPLETED' AS ASSESSMENTS
    FROM [PC].MDS_M_SCHEDULE S INNER JOIN OPTC.MD3_M_MAST M
    ON S.PAT_NUMBER=M.PAT_NUMBER
    LEFT JOIN OGEN.GEN_M_PATIENT_MAST P ON S.PAT_NUMBER = P.PAT_NUMBER
    WHERE S.PAT_NUMBER=M.PAT_NUMBER AND M.REFERENCE_DATE < GETDATE()
    AND S.A3A_DATE_USER BETWEEN @FromDate AND @ToDate
    AND S.FACILITY_KEY IN (SELECT Value FROM dbo.ListToTable(@FACILITYKEY,','))
    AND ( @UNITSTR IS NULL
    OR @UNITSTR = ''
    OR CHARINDEX(P.UNIT_CODE, @UNITSTR)% 2 = 1 ))

    UNION ALL

    (SELECT * FROM (
    (SELECT S.FACILITY_KEY, S.PAT_NUMBER, S.A3A_DATE_USER, M.REFERENCE_DATE ,
    RTRIM(P.LAST_NAME) + CASE WHEN RTRIM(P.FIRST_NAME) <> '' THEN ', '
    ELSE ''
    END + RTRIM(P.FIRST_NAME) PATIENT_NAME
    ,CASE WHEN P.NURSING_UNIT is not null THEN P.NURSING_UNIT ELSE '' END NURSING_UNIT
    ,CASE WHEN P.UNIT_CODE is not null THEN P.UNIT_CODE ELSE '' END UNIT_CODE, 'LATE' AS ASSESSMENTS
    FROM [PC].MDS_M_SCHEDULE S INNER JOIN OPTC.MD3_M_MAST M
    ON S.PAT_NUMBER=M.PAT_NUMBER
    LEFT JOIN OGEN.GEN_M_PATIENT_MAST P ON S.PAT_NUMBER = P.PAT_NUMBER
    WHERE M.REFERENCE_DATE < GETDATE() AND S.A3A_DATE_USER BETWEEN @FromDate AND @ToDate
    AND ( @UNITSTR IS NULL
    OR @UNITSTR = ''
    OR CHARINDEX(P.UNIT_CODE, @UNITSTR)% 2 = 1 )
    ) --Started

    UNION ALL

    (SELECT S.FACILITY_KEY, S.PAT_NUMBER, S.A3A_DATE_USER, NULL AS REFERENCE_DATE,
    RTRIM(P.LAST_NAME) + CASE WHEN RTRIM(P.FIRST_NAME) <> '' THEN ', '
    ELSE ''
    END + RTRIM(P.FIRST_NAME) PATIENT_NAME
    ,CASE WHEN P.NURSING_UNIT is not null THEN P.NURSING_UNIT ELSE '' END NURSING_UNIT
    ,CASE WHEN P.UNIT_CODE is not null THEN P.UNIT_CODE ELSE '' END UNIT_CODE, 'LATE' AS ASSESSMENTS
    FROM [PC].MDS_M_SCHEDULE S INNER JOIN OPTC.MD3_M_MAST M
    ON S.PAT_NUMBER=M.PAT_NUMBER
    LEFT JOIN OGEN.GEN_M_PATIENT_MAST P ON S.PAT_NUMBER = P.PAT_NUMBER
    WHERE S.PAT_NUMBER NOT IN (SELECT M.PAT_NUMBER FROM [PC].MD3_M_MAST M)
    AND S.A3A_DATE_USER < GETDATE() AND S.A3A_DATE_USER BETWEEN @FromDate AND @ToDate
    AND ( @UNITSTR IS NULL
    OR @UNITSTR = ''
    OR CHARINDEX(P.UNIT_CODE, @UNITSTR)% 2 = 1 )) --Not Started
    ) LATE
    WHERE FACILITY_KEY IN (SELECT Value FROM dbo.ListToTable(@FACILITYKEY,',')))

    END

    GO
  • 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-26T14:46:48+00:00Added an answer on May 26, 2026 at 2:46 pm

    Standard SQL:

    COALESCE(P.NURSING_UNIT, '') AS NURSING_UNIT, 
    COALESCE(P.UNIT_CODE, '') AS UNIT_CODE, 
    CASE 
       WHEN M.SIGN_DATE IS NULL THEN 'UNCOMPLETED' 
       ELSE 'COMPLETED' 
    END AS ASSESSMENTS
    

    If your vendor provides a REPLACE() function:

    COALESCE(P.NURSING_UNIT, '') AS NURSING_UNIT, 
    COALESCE(P.UNIT_CODE, '') AS UNIT_CODE, 
    COALESCE(REPLACE(M.SIGN_DATE, M.SIGN_DATE, 'COMPLETED'), 'UNCOMPLETED') AS ASSESSMENTS
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

select case when cntrctr_lcns_seq_no is null then 1 else max(cntrctr_lcns_seq_no) end as cntrctr_lcns_seq_no from
CASE WHEN VPN_Access__c = True THEN 'Need to Setup' + VPN_Access__c ELSE '' END
CASE WHEN system_type__c IS NOT NULL THEN 'Please setup a new system [' +
case class Test(kind: Int) { val ifX = if (isX) is X else not
case i of 0..99 : Function-call('bobo') ; 100..209 : function-smell('Hobo'); 210..300 : function-yikes('argh'); end;
CASE: the form contains input text for entering department name (can't be null or
(In case you do not know, TC++PL stands for The C++ Programming Language, a
select (case when t.freeplayabandoned != f.freeplayabandoned then 'freeplayabandoned' when t.freeplaydownloaded != f.freeplaydownloaded then 'freeplaydownloaded'
case CROP_FROM_CAMERA: if(mImageCaptureUri!=null){ Bundle extras = data.getExtras(); if (extras != null) { Bitmap photo
CASE WHEN [col1] = 's' THEN 8 WHEN [col1] = 't' THEN 6 WHEN

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.