[] PGSQL pgsql in distinct and distinct on usage

 

distinct and distinct on the differences and relations

1. distinct usage

Syntax: select distinct column name [, column name ...] from the table name
distince role: to the weight of the column ---- remove a (poly) column duplicate values

 

 

2. distinct on usage

XXX taken to achieve the most from each data packet a

Syntax: select distinct on (grouping column name) column name [, column names ...] from the table name

distince on the role: to set the weight ---- The recording "(grouping column name)" values are grouped, and return to the first row of each group after the grouping.

 

   a. If no order by clause, the first returned data is random.

 

    b. Using the order by clause, the first data is returned is determined, a data taking can be realized in most XXX

 

 

Guess you like

Origin www.cnblogs.com/xsjs/p/10971752.html