${if(pklb="1","select *fromxxx ","select *fromxxx where${if(count(split(period,","))=1,"quarter_id='"+CONCATENATE(INDEXOFARRAY(REVERSEARRAY(split(period,",")),1))+"'","month_id='"+REPLACE(INDEXOFARRAY(REVERSEARRAY(split(period,",")),1),'-','')+"'")}")}