WbImport
	-type = text
	-mode = 'INSERT,UPDATE'
	-file = D:/dp/tree_data.csv
	-header = true
	-delimiter = ';'
	-schema = nfi_data
	-table = tree
	-keyColumns = id_plot, id_tree
	-importColumns = id_plot, id_tree, species, dbh, height, age

WbExport
	-type = text
	-file = D:/dp/tree_export.txt
	-sourcetable =  nfi_data.tree
	-tableWhere = 'WHERE species = 5 AND dbh >= 180'
	-header = true
	-delimiter = ';'
	-decimal = ','
	-lineEnding = crlf
	-encoding = UTF8
	-compress = true;

WbCopy
	-sourceProfile = TEST
	-targetProfile = TEST
	-mode = 'UPDATE,INSERT'
	-sourceQuery = 	'
										SELECT 
											t.species, 
											p.district, 
											count(t.id_tree) 				AS tree_count, 
											round(avg(t.height),2) 	AS mean_height
										FROM nfi_data.tree 				AS t
										LEFT JOIN nfi_data.plot 	AS p 
											ON (p.id_plot = t.id_plot)
										WHERE t.height IS NOT NULL
										GROUP BY t.species, p.district;
									'	
	-targetTable = nfi_data.tree_summary
	-keyColumns = species, district
	-columns = species, district, tree_count, mean_height;
