Select min group by another column

I have table consisting of these fields:

id  |   GroupId | position      
 ------------------------------------
 CK1         10       1
 CK1         10       2    
 CK1         10       3    
 CK1         11       4    
 CK1         11       5    
 CK1         11       6    
 CK1         12       7    
 CK1         12       8    
 CK1         12       9 

I need a select that includes the min value of position in the group of the registre:

id  |   GroupId | position   | MinPosition         
 -------------------------------------------
 CK1         10       1             1
 CK1         10       2             1    
 CK1         10       3             1    
 CK1         11       4             4
 CK1         11       5             4
 CK1         11       6             4
 CK1         12       7             7
 CK1         12       8             7
 CK1         12       9             7

Thanks


Source: sql

Leave a Reply