Solved

Using a wildcard or LIKE statement inside a DECODE

Posted on 2004-08-19
3
1,617 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
  • 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Abstract Express Replacement Software 12 24
Webservices in T-SQL 3 31
Why Delete * statement wont work with sql server ? 6 41
Sql Query 6 65
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

776 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