Why do the MAX () and MIN () functions give me the same result in Mysql?

0

Why do the MAX () and MIN () functions give me the same result in Mysql?

INSERT INTO 'Venta'('idVenta','idFactura','idVehiculo','Cantidad','Precio') VALUES ('56', '44', '06','01','4000000');
INSERT INTO 'Venta'('idVenta','idFactura','idVehiculo','Cantidad','Precio') VALUES ('57', '45', '07','01','8500000');
INSERT INTO 'Venta'('idVenta','idFactura','idVehiculo','Cantidad','Precio') VALUES ('58', '46', '08','01','7000000');
INSERT INTO 'Venta'('idVenta','idFactura','idVehiculo','Cantidad','Precio') VALUES ('59', '47', '09','01','3100000');
INSERT INTO 'Venta'('idVenta','idFactura','idVehiculo','Cantidad','Precio') VALUES ('60', '48', '10','01','1200000');
INSERT INTO 'Venta'('idVenta','idFactura','idVehiculo','Cantidad','Precio') VALUES ('61', '49', '11','01','4500000');
INSERT INTO 'Venta'('idVenta','idFactura','idVehiculo','Cantidad','Precio') VALUES ('62', '50', '12','01','5300000');
INSERT INTO 'Venta'('idVenta','idFactura','idVehiculo','Cantidad','Precio') VALUES ('63', '51', '13','01','11500000');
INSERT INTO 'Venta'('idVenta','idFactura','idVehiculo','Cantidad','Precio') VALUES ('64', '52', '14','01','6300000');
INSERT INTO 'Venta'('idVenta','idFactura','idVehiculo','Cantidad','Precio') VALUES ('65', '53', '15','01','12000000');
INSERT INTO 'Venta'('idVenta','idFactura','idVehiculo','Cantidad','Precio') VALUES ('66', '54', '06','01','4000000');
INSERT INTO 'Venta'('idVenta','idFactura','idVehiculo','Cantidad','Precio') VALUES ('67', '55', '15','01','12000000');


Select MIN(Precio) from venta;


Select MAX(precio) from venta;
    
asked by Cote Díaz 24.01.2018 в 23:59
source

2 answers

2

I have reproduced your inserts and I have made the queries that you say and this is the result that I get ... Look carefully at the quantities, as it happens that the minimum is "a zero smaller" than the maximum .. Can you not have realized that?

    
answered by 25.01.2018 / 10:57
source
0

Assuming that the table has the correct structure, I imagine that perhaps it is an interpretation problem, min / max brings the lowest / highest value, not the entire row so it will mix information, to select the row with minor / higher price should be like this:

SELECT idVenta, precio FROM Venta ORDER BY precio ASC LIMIT 1;

I leave the examples of the table and queries in SQL FIDDLE .

Greetings.

    
answered by 25.01.2018 в 03:26