Skip to content
Advertisement

SQL CASE WHEN (1=1) What is the 1=1 doing?

I have a SQL statement that I did not write and I am trying to get my head around it.

Can someone please explain what the (1=1) is doing please?

From researching this online my interpretation is that 1=1 means always true, so this would mean the case statement would always return the amt field?

However this doesn’t seem to make sense as this would mean none of the other conditions would ever be met?

Advertisement

Answer

It is placeholder for always true(typical usage is for debug/testing):

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