SELECT
  mk.menesine_kainaid,
  mk.metai,
  mk.menuo,
  mk.kaina,
  mk.comments,
  s.sutartiesid,
  s.sutartisid,
  k.kodas AS kliento_kodas
FROM public.menesine_kaina mk
JOIN public.sutartis s ON s.sutartisid = mk.sutartisid
JOIN public.klientas k ON k.klientasid = s.klientasid
WHERE s.sutartiesid = %s
ORDER BY mk.metai, mk.menuo;
