--ALTER TABLE "public"."ats_data_2015" ADD CONSTRAINT "ats_resolver" UNIQUE ("station_name","transmitter","sampletimestamp")

--select transmitter, COUNT( transmitter ) as "pings" FROM ats_data_2015  group by transmitter order by "pings";
--select distinct transmitter from ats_data_2015 where station_name like '%TC%'
--select transmitter  ,station_name from ats_data_2015 partition by station_name 

--SELECT transmitter, count(station_name) OVER (PARTITION BY transmitter, station_name ) FROM ats_data_2015 limit 20;

--select distinct transmitter from ats_data_2015 where station_name like '%TC%'
--select distinct station_name from ats_data_2015

--select * from ats_data_2015 where transmitter = 'H170-1802-33732';
--SELECT DISTINCT ON (transmitter ) transmitter , station_name FROM ats_data_2015 group by transmitter, station_name;
--select transmitter, COUNT( transmitter ) as "pings" FROM ats_data_2015  where   sampletimestamp > '2015-02-12'::timestamp and transmitter IN
--(select distinct transmitter from ats_data_2015 where station_name like '%CVP%') group by transmitter order by "pings";


--select transmitter FROM ats_data_2015 where station_name like ;


SELECT distinct transmitter
FROM   ats_data_2015
WHERE transmitter IN (SELECT transmitter FROM ats_data_2015 WHERE station_name  like '%HOR%')
AND   transmitter NOT IN (SELECT transmitter FROM ats_data_2015 WHERE station_name  like '%SJG%')
AND   transmitter NOT IN (SELECT transmitter FROM ats_data_2015 WHERE station_name  like '%TC%')
AND   transmitter IN (SELECT transmitter FROM ats_data_2015 WHERE station_name  like '%RGD%')
--AND   transmitter IN (SELECT transmitter FROM ats_data_2015 WHERE station_name  like '%CVP%')



