Use of MAX and MIN functions in postgresql

0

I have a table like the one shown below (simplified example):

Customer_ID Orders
   1 10
   2 15
   3 5
   4 8

Now I would like to generate an extra column that is the maximum value of the Orders column, that is, in the four rows a 15 should appear, but when I try it only calculates the maximum of the row, that is, that duplicates the Orders column.

Thank you very much in advance.

Greetings.

    
asked by Á. Garzón 28.09.2018 в 11:00
source

1 answer

0

After seeing what you say in the comment, I think what you're looking for is the following:

select ID_Cliente, Pedidos, (select max(Pedidos) 
                             from my_table) as mayor_pedido
from my_table
    
answered by 28.09.2018 в 11:21