Select
case when COALESCE (name1, name2, …) in ('rik','mike','john') then
UPPER(Left(COALESCE (name1, name2, …), 2))
else
UPPER(Left(COALESCE (name1, name2, …), 1))
End
from
table1
Select
case
when <условие при котором надо брать 2 символа с начала строки> then
UPPER(Left(name, 2))
when <условие при котором надо брать 2 символа не с начала строки> then
SUBSTRING ( name, <Номер первого символа в строке>, <Количество символов>)
Например SUBSTRING ( name, 2, 2) -- вернет 2 и 3 символ
else
UPPER(Left(name, 1))
end
from
table1
Select Distinct
CommentTable.user_id,
CommentTable.comment,
CommentTable.created_ts
From
comments as CommentTable
Inner join
(Select
t.user_id as user_id ,
Max(t.created_ts) as LastTime
From comments as t
Group by t.user_id) as LastTimeTable
On CommentTable.user_id = LastTimeTable.user_id
and CommentTable.created_ts = LastTimeTable.LastTime