sql case when in where condition I’m trying to convert a sql code to python, have added the sqlfiddle here