contact_telecenter_temp.sql 909 Bytes
Newer Older
1 2 3
-- Query which generated the table contact_temp used in the
-- creation step of the simmctic database
-- for details check simmctic/database/create/data/001-load_data_telecenter.sql
4
-- and simmctic/database/create/data/contact_telecenter_temp.csv
5 6 7 8 9
-- WARNING: Some telecenters were inserted without id_onid. Such telecenters
-- cannot be identifyed unically (without id_point) and are removed of this
-- query.


10
COPY(
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
SELECT
    t.id_onid
    , ct.name AS "responsible_name"
    , ct.rg AS "responsible_rg"
    , ct.cpf AS "responsible_cpf"
    , ct.post AS "responsible_post"
    , ct.phone1 AS "responsible_phone_1"
    , ct.phone2 AS "responsible_phone_2"
    , ct.phone3 AS "responsible_phone_3"
FROM
    point p
    INNER JOIN telecenter t ON p.id = t.id_point
    INNER JOIN contact ct ON p.id = ct.id_point
WHERE
    t.id_onid IS NOT NULL
    AND p.is_active
27
) TO STDOUT WITH CSV HEADER DELIMITER ';';