I am having a problem with using the MIN and MAX function in Microsoft SQL Server
The problem is regarding MIN and MAX functions displaying the results incorrectly.
My query is like this:
SELECT
MIN(compression_ratio) AS minimum_cr,
MAX(compression_ratio) AS maximum_cr
FROM dbo.C4m3practice
and it returns the MIN value 10 and MAX value 9.6, which doesn’t make sense and is also both wrong.
I’ll attach a picture below. What am I doing wrong?
>Solution :
Seems like compression_ratio of type varchar(), you will need to convert your column to float
Try this :
SELECT
MIN(CAST(compression_ratio as float)) AS minimum_cr,
MAX(CAST(compression_ratio as float)) AS maximum_cr
FROM dbo.C4m3practice