Relative Content

Tag Archive for pythonnestedconditional-operatorf-string

Nested f string with conditional or ternary operator in Python

I’ve got an f-string expression to build a sql select query and I’m using the following expression within the select f-string. Here my inner expression is resolved but it leaves the f”’ ” within the string and it breaks the query. Can someone please help
f”’
… left join (select a, b, sum(c)/sum(d) as c1,
… (sum(e)/sum(d))/(sum(f)/sum(d)) as c2
… from {{actual_output_tbl}}
… group by 1, 2) out
… on t1.col1= t2.col1 and t1.col2= t2.col2
… ”’ if count == 1 else “”