create or replace view vBluesealUsers as
SELECT
  `u`.`id`                                            AS `id`,
  `ud`.`name`                                         AS `name`,
  `ud`.`surname`                                      AS `surname`,
  `u`.`email`                                         AS `email`,
  if((`ud`.`gender` = 'F'), 'Donna', 'Uomo')          AS `sex`,
  if((`u`.`isActive` = 1), 'Attivato', 'Disattivato') AS `status`,
  `u`.`creationDate`                                  AS `creationDate`
FROM (`User` `u`
  JOIN `UserDetails` `ud`)
WHERE (`u`.`id` = `ud`.`userId`) and u.isDeleted = 0
ORDER BY `u`.`creationDate` DESC