Home Analytics

Analytics Query Question

Larry_GrantLarry_Grant Member IT Monkey ✭

I have a SQL query I am trying to override the data in a column with the GUID and replace it with the value.


The below query works:

select * From dbo.SM_WorkItem_Incident

Where Tier = 'Maintenance' and (statusid = 'A6341E80-B9B2-7778-2D73-D8BD979AA9E2' or StatusId = '5E2D3932-CA6D-1515-7310-6F58584DF73E')


When I add a case statement like below it no longer works.:

select * From dbo.SM_WorkItem_Incident

Where Tier = 'Maintenance' and (statusid = 'A6341E80-B9B2-7778-2D73-D8BD979AA9E2' or StatusId = '5E2D3932-CA6D-1515-7310-6F58584DF73E')

Case BLDNMB_5D49AF3B_5420_9F0C_0E61_6D6A526829BE

When 'CD800D4C-A13F-5446-D025-77FCFDD1D165' Then 1

When '4ACD0C42-69F2-C317-331D-936CF9EE4DAB' Then 4

When '5A370D65-F7AB-628C-A460-6973B6AFC715' Then 5

When 'D5DFBA03-0D9A-4128-7FD7-BD0FBA1F5BF4' Then 6

When '324F5771-1621-F73C-D82A-0A2E5A8E564B' Then 7

When 'B41BC84A-9DA5-5189-3680-EC2A8DB78B47' Then 8

When 'A1C90D22-2CFF-A9BC-8ED9-6CCDB9FE6DCF' Then 9

When '6F96DB99-254E-B53C-8C88-4B3C11BC5D74' Then 10

When '803549F0-2DF4-3DE7-2655-9B376507FB1A' Then 11

When '88C0EB1B-8971-951E-E96C-B5FB5C6AB2EA' Then 12

When 'F7E84F01-BB51-D67D-0610-174A2A89BA7B' Then 13

When 'A983D326-C4F6-3137-F7EC-A5FDCEBB4772' Then 14

When '33441804-A45E-6D57-3D44-BB6DD7AE5BB9' Then 15

When '9504FC45-AC18-8239-A088-98216D8FD22F' Then 16

When '85885CDE-E8A5-74CE-24C9-95530236768B' Then 17

When 'B1D6DD01-D513-68B1-A656-BE916108DDF6' Then 18

When '1D48FBE6-DC20-A614-44F1-BC183A7337C5' Then 19

When '4B3C50A4-06D6-CE41-E103-8D48D342B2D0' Then 20

When 'FD527472-C337-D8C2-DE3E-D16C8E164910' Then 21

When 'E6F3901A-0F5A-76AA-4057-2EA0E195DCD6' Then 40

When '9EEC2B9A-4F22-F8B8-E03D-EE2D00492C4C' Then 41

When '65FC85B4-2838-2086-6E7B-FF3CB330A0C2' Then 42

When '8224DE1D-C43B-D82D-D2A6-27EAC5FDB409' Then 43

When '816D870A-03F4-2DF6-C4AB-2C5475037D41' Then 44

When '769D325F-3CF2-8ACC-EDA9-ADAB40989477' Then 45

When '203EDFEC-FF99-42A6-B3CB-4B886B5719CB' Then 46

When '71A3A961-D91B-6FA2-4061-FDF86F89E604' Then 47

When 'A15CAB82-4AAF-0C20-4C86-B05FCA068601' Then 60

When 'C438B37F-D938-D456-9A5D-EA458617FD5C' Then 61

When '0DEF7141-43C9-1E38-D7DE-EBE65E45664E' Then 62

When '9AD72FCE-43E8-05CA-E4F4-2BE47F04693F' Then 63

When '458604E1-8E96-BE79-5130-DCE6363E1B29' Then 64

When 'D62F060F-C971-2571-1674-9C9F85200464' Then 80

When '189C90D5-5634-A9C4-1B61-1ADB74476A33' Then 81

When '4677AEC5-D875-1E29-AA56-47A20F0F11B2' Then 82

When '759C5D6E-756D-5FA9-F029-5A1D1216EED7' Then 90

When '0729D681-7CC3-07E4-4381-BB53CA26BAFB' Then Grounds

Else NULL


Any advise or assistance is appreciated.

Best Answer

  • Brad_ZimaBrad_Zima Member Advanced IT Monkey ✭✭✭
    Answer ✓

    @Larry_Grant It looks like your SQL query is trying to translate the statuses into their display string value, have you considered doing a join against the DisplayStrings table to just return the display value?

Answers

  • Brad_ZimaBrad_Zima Member Advanced IT Monkey ✭✭✭
    Answer ✓

    @Larry_Grant It looks like your SQL query is trying to translate the statuses into their display string value, have you considered doing a join against the DisplayStrings table to just return the display value?

Sign In or Register to comment.