question

trishhfernandez avatar image
trishhfernandez asked

How to display values from other columns when value is special

I am trying to figure out my CASE logic if the value of FABRIC RANGE column = _SPECIAL, then display the value of Description column. So, we currently get the below: PO NUMBER FABRIC RANGE DESCRIPTION P18030096 Fiesta Indigo Indigo P18030097 _SPECIAL Dolly Denim P18030098 Quantum Nebula Nebula P18030098 _SPECIAL Dolly Magenta What we want is it to see is to give this result: PO number Fabric Range Description P18030096 Fiesta Indigo Indigo P18030097 Dolly Denim Dolly Denim P18030098 Quantum Nebula Nebula P18030098 Dolly Magenta Dolly Magenta my code is: SELECT dbo.PO.PONo AS [PO Number], dbo.ReceivingDetails.ItemVendorNumber AS [Fabric Range], dbo.ReceivingDetails.Description I know I need to put CASE WHEN, but it might be a good idea :(
sqlservercase
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
ThomasRushton avatar image
ThomasRushton answered
SELECT ... CASE [Fabric Range] WHEN '_SPECIAL' THEN Description ELSE [Fabric Range] END...
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.