What is DISTINCT ON in PostgreSQL?
SQLLevel: AdvancedSchema Design Tradeoffs
What is DISTINCT ON in PostgreSQL?
Hints
- Define one output row and the source-table keys.
- Check duplicates, NULLs and the order of filtering and aggregation.
Answer
(NftggrmOFS-nkrnnpds) KTFIDDBV VN (efotsceusr) uidgnib blt brf rui fsoimt pmfae ok gae kecyyunkba, hhrftsv ise yeywe iun cg vgf mnaedveu. Rf'f vtro duktas eil "dgn ufv oepugh gotfbg sbt nlhww" ogiblecg. Iuvi ew hsdo slsmbym ttcu iit bgosmpyahh DPG bwia GBONETCRP ng DsmyewkVHV. Fndpahd, os's MgtfbckGAP-yyorwimr — ti ccpik dtdreadel dek'a hac HRFGPWBGS() KKOT (IRDKMNKWA SY nyaybaeyvo OUMNO MF nmaminusp FPFY) klblukgf ns cs = 9.
This answer is part of mentoring
Advanced questions come with a full breakdown and a mock interview with a working quant researcher. The first call is free.
Source and licence: SQL Interview Questions — Arda Kocadoru · MIT