 --      * presentconditions, skyconditions, runwayconditions
 -- ===============================================================
 -- metar_reports: create view with training date constraints
-drop table if exists training2_metar_reports;
-create table training2_metar_reports as ( 
+drop table if exists training3_metar_reports;
+create table training3_metar_reports as ( 
     select * from metar_reports where
     date_time_issued >= '2013-11-14 09:00:00+00' and date_time_issued < '2013-12-12 09:00:00+00'
 );
 
 -- presentconditions
-drop table if exists training2_metar_presentconditions;
-create table training2_metar_presentconditions as (
+drop table if exists training3_metar_presentconditions;
+create table training3_metar_presentconditions as (
     select * from metar_presentconditions
-    where metar_reports_id in (select id from training2_metar_reports)
+    where metar_reports_id in (select id from training3_metar_reports)
 );
 -- skyconditions
-drop table if exists training2_metar_skyconditions;
-create table training2_metar_skyconditions as (
+drop table if exists training3_metar_skyconditions;
+create table training3_metar_skyconditions as (
     select * from metar_skyconditions
-    where metar_reports_id in (select id from training2_metar_reports)
+    where metar_reports_id in (select id from training3_metar_reports)
 );
 
 -- runwayconditions
-drop table if exists training2_metar_runwaygroups;
-create table training2_metar_runwaygroups as (
+drop table if exists training3_metar_runwaygroups;
+create table training3_metar_runwaygroups as (
     select * from metar_runwaygroups
-    where metar_reports_id in (select id from training2_metar_reports)
-);
-
-copy (select * from training2_metar_reports) to 'C:/FQ2DataRelease2/training2_metar_reports.csv' delimiter ',' csv header;
-copy (select * from training2_metar_presentconditions) to 'C:/FQ2DataRelease2/training2_metar_presentconditions.csv' delimiter ',' csv header;
-copy (select * from training2_metar_skyconditions) to 'C:/FQ2DataRelease2/training2_metar_skyconditions.csv' delimiter ',' csv header;
-copy (select * from training2_metar_runwaygroups) to 'C:/FQ2DataRelease2/training2_metar_runwaygroups.csv' delimiter ',' csv header;
+    where metar_reports_id in (select id from training3_metar_reports)
+);
+
+copy (select * from training3_metar_reports) to 'E:/FQ2_Data/training3_metar_reports.csv' delimiter ',' csv header;
+copy (select * from training3_metar_presentconditions) to 'E:/FQ2_Data/training3_metar_presentconditions.csv' delimiter ',' csv header;
+copy (select * from training3_metar_skyconditions) to 'E:/FQ2_Data/training3_metar_skyconditions.csv' delimiter ',' csv header;
+copy (select * from training3_metar_runwaygroups) to 'E:/FQ2_Data/training3_metar_runwaygroups.csv' delimiter ',' csv header;
 
 
 -- ===============================================================

;

-- Training: flighthistory
drop table if exists training2_flighthistory;
CREATE table training2_flighthistory as 
    select * from base_flighthistory WHERE 
        (
            published_departure < '2013-12-12 09:00:00+00'

--          This is because NOAA has changed the name of their product
--          to FDwind but did not change column headers
-- ===============================================================
drop table if exists training3_fdwindreport;
create table training3_fdwindreport as (
    select * from fdwindreport where
    createdutc >= '2013-11-14 09:00:00+00' and createdutc < '2013-12-12 09:00:00+00'
);
-- airport using report ids
drop table if exists training3_fdwindairport;
create table training3_fdwindairport as (
    select * from fdwindairport where fbwindreportid in 
        (select fbwindreportid from training3_fdwindreport)
);

-- altitude uses report ids
drop table if exists training3_fdwindaltitude;
create table training3_fdwindaltitude as (
    select * from fdwindaltitude where fbwindreportid in 
        (select fbwindreportid from training3_fdwindreport)
);
-- wind using airport ids
drop table if exists training3_fdwind;
create table training3_fdwind as (
    select * from fdwind where fbwindairportid in
        (SELECT fbwindairportid from training3_fdwindairport)
);

copy (select * from training3_fdwindreport) to 'E:/FQ2_Data/training3_fdwindreport.csv' delimiter ',' csv header;
copy (select * from training3_fdwindairport) to 'E:/FQ2_Data/training3_fdwindairport.csv' delimiter ',' csv header;
copy (select * from training3_fdwindaltitude) to 'E:/FQ2_Data/training3_fdwindaltitude.csv' delimiter ',' csv header;
copy (select * from training3_fdwind) to 'E:/FQ2_Data/training3_fdwind.csv' delimiter ',' csv header;

-- ===============================================================
-- TAF
