~williamvds/dissertation

9aa4e97b9f0bd41b806888504468083886f2a324 — williamvds 4 years ago 1424298
Add data export script
1 files changed, 20 insertions(+), 0 deletions(-)

A scripts/export.sql
A scripts/export.sql => scripts/export.sql +20 -0
@@ 0,0 1,20 @@
DROP TABLE IF EXISTS dedupedOrgProjects;
CREATE TEMP TABLE IF NOT EXISTS dedupedOrgProjects AS
SELECT
	COALESCE(d.orgUuid, o.orgUuid) AS orgUuid,
	po.projectUuid,
	po.role,
	po.startDate,
	po.endDate,
	po.cost::numeric::int,
	po.offer::numeric::int
FROM
	gtrOrgs o
	LEFT OUTER JOIN duplicateGtrOrgs d
		ON d.duplicateUuid = o.orgUuid
	INNER JOIN gtrProjectOrgs po
		ON po.orgUuid = o.orgUuid;

\copy (SELECT * FROM orgs) to data/orgs.csv (FORMAT CSV, HEADER)
\copy (SELECT * FROM gtrProjects) to data/projects.csv (FORMAT CSV, HEADER)
\copy (SELECT * FROM dedupedOrgProjects) to data/orgProjectsLinks.csv (FORMAT CSV, HEADER)