-- View: "v_cast_export"

DROP VIEW "v_cast_export";

CREATE OR REPLACE VIEW "v_cast_export"
AS
SELECT c.castcd,
       c.castnm,
       c.castnmkana,
       c.castdiv,
       n.name AS castdivname,
       c.recommenddiv,
       CASE c.recommenddiv
          WHEN 1 THEN 'おすすめ'
          ELSE ''
       END AS recommenddivname,
       c.comment,
       c.debutdate,
       c.birthplacecd,
       p.prefnm,
       c.birthdate
 FROM t_cast c
      LEFT JOIN t_pref p
         ON p.prefcd = c.birthplacecd
      LEFT JOIN t_name n
         ON n.namediv = 6 AND n.namecd = c.castdiv
WHERE c.delflg = FALSE
ORDER BY c.castnmkana, c.castnm;
