-- ============================================================
-- Step 4: query PostgreSQL directly through the Database Link.
-- PostgreSQL schema, table, view, and column identifiers are
-- lower-case and must be double quoted.
-- Redmine: #730
-- ============================================================

SELECT COUNT(*) AS carrier_count
FROM "hmm_demo"."carriers"@HMM_RDS_PG_LINK;

SELECT
  COUNT(*) AS performance_count,
  MIN("performance_month") AS first_month,
  MAX("performance_month") AS latest_month
FROM "hmm_demo"."carrier_monthly_performance"@HMM_RDS_PG_LINK;

SELECT
  "carrier_code",
  "carrier_name",
  "service_region",
  "performance_tier"
FROM "hmm_demo"."carriers"@HMM_RDS_PG_LINK
ORDER BY "carrier_code";

SELECT
  "carrier_code",
  "carrier_name",
  "performance_month",
  "shipped_teu",
  "revenue_usd",
  "schedule_reliability_pct",
  "risk_level"
FROM "hmm_demo"."carrier_performance_latest_v"@HMM_RDS_PG_LINK
ORDER BY "carrier_code";
