как правильно сделать CONCAT строк через terminal в postgreSQL?

 id |  name  |      pwd       |      email       | gender 
:---+:-------+:--------------:+:----------------:+--------:
  1 | Vasya  | 21341234qwfsdf | [email protected]    | m
  2 | Alex   | 21341234       | [email protected]    | m
  3 | Alexey | qq21341234Q    | [email protected] | m
  4 | Helen  | MarryMeeee     | [email protected]   | f
  5 | Jenny  | SmakeMyb       | [email protected] | f
  6 | Lora   | burn23         | [email protected] | f

я создал таблицу и хочу получить из нее вот такой результат 

+:---------------------------------------------:+
| info                                          |
+:---------------------------------------------:+
| This is Vasya, he has email [email protected]     |
| This is Alex, he has email [email protected]      |
| This is Alexey, he has email [email protected] |
| This is Helen, she has email [email protected]   |
| This is Jenny, she has email [email protected] |
| This is Lora, she has email [email protected]  |

но я ещё не знаю как вывести сразу 6 строк и чтобы получился результат выше, чтобы парни писались через he, а девушки через she.

все что у меня пока получается это делать два запроса и выводить по три строки, и вручную менять he/she. наверное в условии нужно как-то делать привязку к gender, но это не точно

select *, concat ('This is ', name, ', he has email ', email) as info from names where id>=1 and id<=3;

Ответы (1 шт):

Автор решения: Виктор

Вариант

select concat ('This is ', name, ', ',
       (CASE
           WHEN gender = 'm' THEN 'he'
           ELSE 'she'
       END),
 ' has email ', email) as info from names where id>=1 and id<=6;
→ Ссылка