sql("ZI_DATA", "SELECT SUM(payamount) FROM everyday_pay_fk WHERE
1=1 if(len($gsname) == 0,"","and org_name = '" +$gsname+ "'") and dt='" + $dt + "'
and yskm='投资付款-固定资产投资支出-400002002'", 1, 1)
没拼接好,if公式不能写在双引号内
sql("ZI_DATA","SELECT SUM(payamount) FROM everyday_pay_fk WHERE 1=1 "+if(len($gsname)==0,""," and org_name = '"+$gsname+"'")+" and dt='"+$dt+"' and yskm='投资付款-固定资产投资支出-400002002'",1,1)
sql("ZI_DATA", "SELECT SUM(payamount) FROM everyday_pay_fk WHERE 1=1 "+ if(len($gsname) == 0,"","and org_name = '" +$gsname+ "'") + "and dt='" + $dt + "' and yskm='投资付款-固定资产投资支出-400002002'", 1, 1)
可以直接用+号拼接FR公式
sql("ZI_DATA", "SELECT SUM(payamount) FROM everyday_pay_fk WHERE 1=1 "+if(len($gsname) == 0,"","and org_name = '" +$gsname+ "'")+" and dt='" + $dt + "' and yskm='投资付款-固定资产投资支出-400002002'", 1, 1)
SQL(connectionName,sql,columnIndex,rowIndex)
sql:SQL语句,字符串形式; =>用+进行拼接成字符串,
if 判断不是SQL语句中的,而是帆软的内置函数,如果要使用需要从双引号中抽出