A syntax error requires some help

Have a good day everyone
Thank you for trying to help out first.

My question concerns

I'm trying to write and an SQL query that will execute the following
1. When the user enters a certain terminal code, SQL returns the results for that terminal.
2. When the user enters the terminal code with the CN mask, the SQL request returns all terminals that have a CN at the beginning of this terminal.

I know that I will probably need to use the CAS here

Until here I've had,

SELECT sm.terminalid as terminalcode,
sm.sums like Latest_sums
from sums1 sm

CASE

WHEN sm.terminalid =: p_terminal THEN sm.sums = (SELECT max (ss.sums) in sums SS WHERE ss.terminalid =: p_terminal)

WHEN sm.terminalid =: p_terminal AND: p_terminal LIKE & # 39; CN% & # 39; THEN sm.sums = (SELECT sm1.sums FROM sums1 sm1
WHERE sm1.terminalid =: p_terminal
AND: p_terminal LIKE & # 39; CN% & # 39;)
ELSE & # 39; incorrect terminal ID & # 39;
END

Can someone help me where I'm wrong, because the selection does not return multiple results when CN is entered.

Thanks in advance
SEMrush