SELECT "year"."model_variant_id" AS "variantId", "year"."variant_year_id" AS "yearId", "year"."year_release_date" AS "releaseDate", "year"."actual_price" AS "price" FROM (SELECT "variant"."model_variant_id", "endYear"."variant_year_id", "endYear"."year_release_date", "endYear"."actual_price", ROW_NUMBER() OVER (PARTITION BY "variant"."model_variant_id" ORDER BY "endYear"."year_release_date" DESC) AS row_num FROM "models_variants" "variant" INNER JOIN "variants_years" "endYear" ON  "variant"."model_variant_id" = "endYear"."yearVariantModelVariantId" AND "endYear"."deleted_date" IS NULL WHERE "variant"."deleted_date" IS NULL) "year" WHERE "year"."row_num" = 1