Skip to content
Advertisement

Query using min() not showing the correct result

I have this table:

I have these values:

Now the weird thing is that I can not get the correct results with this query:

The result is:

EDIT: What I need is to select the code which have min(viewsT)

I’m sure that I’m missing something really small in the syntax which will bring me downvotes, but I need to know my mistake and learn from it.

Advertisement

Answer

Assuming you want to find the one row with the minimum value, use

If more than one row contains the minimum value you will get all such rows. I.e. if two rows had the value 15 for viewedT, you would get both.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement