1

Hi I need to correct this query, which ends with error:

missing right parenthesis

what's nonsense, problem is probably somewhere else

SELECT name, 
      (name LIKE '%adam%') AS score 
  FROM names 
 ORDER BY score DESC

If is not possible use LIKE in SELECT part, how is possible to list "ADAMS" first ?

user5332
  • 758
  • 2
  • 9
  • 17

3 Answers3

2

try this:

SELECT name, 
       (CASE WHEN (name LIKE '%adam%') THEN 1 ELSE 0 END) AS score
FROM names 
ORDER BY score DESC
slavoo
  • 5,798
  • 64
  • 37
  • 39
0

Oracle SQL doesn't have a boolean datatype, so selecting a boolean value is illegal.

See Is there a boolean type in oracle databases?

Community
  • 1
  • 1
Klas Lindbäck
  • 33,105
  • 5
  • 57
  • 82
0

You can also write a SQL in the order by by replacing the score column