lundi 2 juillet 2018

Oracle db query with if statement

i have a problem with a query.

   SELECT codigo clave,descrip valor
  CASE WHEN codigo  IS NOT NULL THEN  SELECT codigo clave ,codigo || ' - ' || descrip valor
ELSE
  CASE WHEN codigo  IS  NULL  SELECT codigo clave , descrip valor
END

i need to concat the code and "-" to make some like this 1 - option 2 - option but the problem is some times the code is empty and print: - option - option Sorry my bad english and thanks!

Aucun commentaire:

Enregistrer un commentaire