Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a CASE statements in a PIVOT role #98

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

tznind
Copy link
Contributor

@tznind tznind commented Nov 5, 2021

This task is promoted from jira:

MySql only issue?

When you have a pivot column that contains select SQL that has quotes in it then this can mess with dynamic SQL needed to generate an axis/pivot graph e.g. the following select sql:


  CASE
    WHEN BodyPartExamined like '%SMI_REDACTED%' THEN 'BodyPartExamined'
    WHEN InstitutionName like '%SMI_REDACTED%' THEN 'InstitutionName'
    WHEN Modality like '%SMI_REDACTED%' THEN 'Modality'
    WHEN PerformedProcedureStepDescription like '%SMI_REDACTED%' THEN 'PerformedProcedureStepDescription'
    WHEN ProcedureCodeSequence_CodeValue like '%SMI_REDACTED%' THEN 'ProcedureCodeSequence_CodeValue'
    WHEN ProtocolName like '%SMI_REDACTED%' THEN 'ProtocolName'
    WHEN SeriesDescription like '%SMI_REDACTED%' THEN 'SeriesDescription'
    WHEN SeriesInstanceUID like '%SMI_REDACTED%' THEN 'SeriesInstanceUID'
    WHEN StudyInstanceUID like '%SMI_REDACTED%' THEN 'StudyInstanceUID'
    ELSE null
END

The workaround is to use double quotes when you express the SQL. 

@tznind tznind changed the title Added test for using a CASE statement in a PIVOT Using a CASE statements in a PIVOT role Nov 5, 2021
@jas88
Copy link
Member

jas88 commented Aug 29, 2022

Could this be related to #150, dodgy escaping via REPLACE not quite getting it right in some cases when the proper QUOTE function does?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants