Solved

Using a wildcard or LIKE statement inside a DECODE

Posted on 2004-08-19
3
1,665 Views
Last Modified: 2008-02-26
I am trying to use a decode statement to translate a statement into a true/false values.
I have tried using:
DECODE( A.Problem_History, '%Duplicated%', 'True', 'False')
DECODE( A.Problem_History, '*Duplicated*', 'True', 'False')
but neither of those work for finding those which contain the work 'Duplicated' in the Problem_History column.

My next thought was to try a LIKE statement and if its true, pass 'True' as the returned value.
DECODE( (A.Problem_History LIKE '%Duplicated%'), 'True', 'True', 'False')

This however returns a "ORA-00907: Missing right parenthesis" error and highlights the 'LIKE' keyword.

0
Comment
Question by:Pawlikj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 69

Expert Comment

by:Scott Pletcher
ID: 11841858
You will likely have better luck placing this in the Oracle forum rather than the SQL Server one :-)
0
 
LVL 10

Expert Comment

by:Jay Toops
ID: 11842061
AND you cant use like in a decode statement ..
0
 
LVL 10

Accepted Solution

by:
Jay Toops earned 250 total points
ID: 11842253
you can do this though

case when A.Problem_History like '%duplicated%' then 'true'
else 'false'
end as bDuplicated
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question