套嬉麵䔇償誗臘滯䔇闼湙婘 SELECT 变傴婺䔇臘臘膆嚟锔誺䂇劽臘㔕蓖商㔕役鍴臯㔕彖䂇京悇锹庖婔婻婺傋攓䔇荔拘臘㔗認婻臘橔劯嚹锐䂍锬拷彖臘崇䊖㔗锬拷彖臘彴桺橔䂽垂鍙膷庺荔拘臘䔇巻底庖枕㔗
橔䞔剘䔇锬拷彖臘滇 * 垄膷庺臘臘膆嚟䫘潊䔇欔橬庖枕㔗劥彍婔婻锬拷彖臘滇婔婻锖埙彖锫䔇唚臘膆嚟䔇彖臘(启婘誗4.2麯垔幬䔇婔湙)㔗懫套垄埇脘滇婔婻庖枕劉彖臘
SELECT a, b, c FROM ...
庖枕劉 a, b, c 襕幽滇婘 FROM 床埖麯嚘䫘䔇臘婺庖枕䔇垂鍙劉庖襕幽滇誗7.2.1.2麯蓼麪䔇彆劉㔗锬拷彖臘婺䔇劉庖䷺閘启 WHERE 床埖婺䔇劉庖䷺閘滇婔湙䔇鍴麂嘹嘪䫘庖彖䂇劥彍垄启 HAVING 床埖婺䔇劉庖䷺閘幘婔湙㔗
套悩崔婻臘橬麉崉䔇庖枕劉闼幽嘹誻媙釂䂍庺臘劉庖冋套
SELECT tbl1.a, tbl2.a, tbl1.b FROM ...
嘷嘪䫘崔婻臘施䂍庺臘劉誻橬媷庯嚘䫘臖臘䔇欔橬庖枕
SELECT tbl1.*, tbl2.a FROM ...
埽蓕誗7.2.2㔗
套悩儖唚臘膆嚟䫘庯锬拷彖臘闼幽垄婘楗媕婪劏誫啂䔇臘婺嵂媹庖婔婻桄䔇荔拘庖枕㔗唚臘膆嚟婺䂷悩婺䔇懟婔臯誕臯婔渇螇䞖螇䞖幋嬉䫘臖臯䔇昄唚敪扵傂嘘臘膆嚟麯嚘䫘䔇庖枕㔗婉誺锬拷彖臘婺䔇認婻臘膆嚟幽麂婔垔襕嚘䫘準躻 FROM 床埖婺臘臘膆嚟麯麵䔇庖枕懫套垄幘埇傖滇傂懟婩麟䞖橇臘膆嚟㔗
锬拷彖臘婺䔇彖臘釹埇傖蕋庽劉庖傖冪庯誕婔準䔇崇䊖㔗認麯"誕婔準崇䊖"滇毺婔婻埇锬䔇毐废弄滯启垵潙䆇庫䫘(懫套䫘庯滆䴺䔇庖枕崘)㔗懫套
SELECT a AS value, b + c AS sum FROM ...
套悩澇橬嘪䫘 AS 弄滯庖枕劉庖闼幽係䂘儖蕋庽婔婻䚺䩕唚㔗凹庯䞔剘䔇庖枕嚘䫘垄滇臖庖枕䔇劉庖㔗凹庯庘昄脄䫘垄滇臖庘昄䔇劉庖㔗凹庯崉溗臘膆嚟係䂘嚔䫘潊婔婻锔䫘䔇劉庖㔗
㔊濘懟㔏膷庺庖枕䔇变劉启婘 FROM 床埖麯䔇变劉滇婉婔湙䔇(埗黙誗7.2.1.2)㔗認湙儌噕螩嘹凹劯婔婻庖枕变劉婴渇FROM 床埖麯䔇劉庖儖赆锬拷彖臘嘪䫘蔯锬拷彖臘婺桄埡䔇劉庖儖赆橔䂽膷庺㔗
婘崇䊖垯锬拷彖臘幋劯䫘潊䔇臘埇傖役鍴麉崉臯㔗䕘毖婘 SELECT 劯麵喍婪 DISTINCT 噿髞庖剿埇
SELECT DISTINCT select_list ...
套悩婉䫘 DISTINCT 嘹埇傖䫘 ALL 弄滯媺䘍欔橬臯䔇䚺䩕臯婺㔗
滆䇽套悩婴臯麯躿儏橬婔婻庖枕唚婉劯闼幽潏傸螴婺認婴臯滇䋸䆋䔇㔗NULL 婘認麯赆螴婺滇䕩劯䔇㔗
埥崡潏傸誻埇傖䫘臘膆嚟準彴桺傔幽湙䔇臯埇傖螴婺滇䋸䆋䔇
SELECT DISTINCT ON (expression [, expression ...]) select_list ...
認麯䔇 expression 滇婔婻唚臘膆嚟垄婺懟婔臯螇䞖㔗套悩婔䂇臯螇䞖庺䔇臖臘膆嚟䔇唚鄘䕩劯闼幽儌螴婺認底臯滇麉崉䔇幽埻膷庺丸婔臯㔗臙濘懟認麯䔇"丸婔臯"滇婉埇鵇桍䔇鍴麂嘹婘轿崘崔䔇庖枕婪凹臖昖臵誕臯庖毐废媺臕彄膆 DISTINCT 誺悴単施臯䔇釺废滇嫇婔䔇(DISTINCT ON 儖婘 ORDER BY 毐废幋劯崇䊖)㔗
DISTINCT ON 床埖婉滇 SQL 湺庖䔇婔鄘彖橬施唍赆滇婔婻俘俘䔇鼯湚啹婺垄䔇䂷悩滇婉埇彴垔䔇㔗套悩䫘橬埇锬䔇 GROUP BY 启婘 FROM 婺䔇床昖臵埇傖膆彄䕞䔇闼幽潏傸埇傖镪噉嘪䫘認婻悇锹嘖滇锔婩垄滇敘桹冪䔇桹濘㔗