Your biggest mistake is in the incorrect use of CASE syntax .
CASE input_expression
WHEN when_expression THEN result_expression [ ...n ]
[ ELSE else_result_expression ]
END
Do not give too much understanding of what you are trying to do, but if you want the return to be 2 at the value log that is in TIPOUSUARIO
, you can use its case
in select
as well. p>
USE DATABASE
SELECT case when TIPOUSUARIO = 'A' THEN '2' END
FROM TABLE UP (NOLOCK)
GO
Now if you use case
in where
would be.
USE DATABASE
SELECT TIPOUSUARIO
FROM TABLE UP (NOLOCK)
WHERE
TIPOUSUARIO = case when TIPOUSUARIO = 'A' THEN '2' END
GO
this would work if there is TIPOUSUARIO = 'A'
and TIPOUSUARIO = '2'
.