@SQL(value="select a.grpcontno,a.province,(select placename from ldaddress where placetype='01' and placecode=a.province),a.city,(select placename from ldaddress where placetype='02' and placecode=a.city),a.county,(select placename from ldaddress where placetype='03' and placecode=a.county),a.address,a.zipcode from LCGrpContactInfo a where 1=1 @{0}",clauses={
@SQL(value="select a.grpcontno,a.province,(select placename from ldaddress where placetype='01' and placecode=a.province),a.city,(select placename from ldaddress where placetype='02' and placecode=a.city),a.county,(select placename from ldaddress where placetype='03' and placecode=a.county),a.address,a.zipcode,a.linkprovincecode,(select placename from ldaddress where placetype='01' and placecode=a.linkprovincecode), a.linkcitycode,(select placename from ldaddress where placetype='02' and placecode=a.linkcitycode),a.linkcountycode,(select placename from ldaddress where placetype='03' and placecode=a.linkcountycode),a.linkdetailaddr\n from LCGrpContactInfo a where 1=1 @{0}",clauses={
@SQL(value="select a.TaxpaperFlag,(select m.codename from ldcode m where m.codetype='invoicetypeflag' and m.code=a.TaxpaperFlag ),a.TaxpayerName,a.TaxpayerNo,a.BankName,a.BankAccNo,a.Phone,a.Address,a.IsElecInvoicePrint,(select CodeName from ldcode where CodeType ='iselecinvoiceprint' and Code = a.IsElecInvoicePrint),a.ElectInvoiceEmail from LCGrpInvoiceDetail a where 1=1 @{0}",clauses={
@SQL(value="select a.TaxpaperFlag,(select m.codename from ldcode m where m.codetype='invoicetypeflag' and m.code=a.TaxpaperFlag ),a.TaxpayerName,a.TaxpayerNo,a.BankName,a.BankAccNo,a.Phone,a.Address,a.IsElecInvoicePrint,(select CodeName from ldcode where CodeType ='iselecinvoiceprint' and Code = a.IsElecInvoicePrint),a.ElectInvoiceEmail,a.fuli,(select codename from ldcode where codetype='trueflag' and code=a.fuli),a.taxpayer,(select codename from ldcode where codetype='taxpayer' and code=a.taxpayer),a.invoice,(select codename from ldcode where codetype='invoice' and code=a.invoice) from LCGrpInvoiceDetail a where 1=1 @{0}",clauses={
@SQL(value="select * from (select a.grpcontno,a.prtno,(select codename from ldcode where codetype = 'salechannel' AND code = a.agenttype),b.name,a.CValiDate,(SELECT f.activityname FROM lwactivity f WHERE f.ActivityID=w.ActivityID),( SELECT codename FROM ldcode where codetype = 'contstate' AND code = a.state),( SELECT sum(j.sumduepaymoney) FROM ljspay j where j.otherno = a.grpcontno AND j.paycount = '1' AND j.state = '2'),a.firstpaydate,( SELECT t.contplantype FROM lcproposal t WHERE t.grppropno = a.prtno), a.manageCom,c.AgentCode CustomerNo , a.agenttype,a.makedate from lcgrpcont a,lwmission w,lcgrpappnt b ,LCAgentToCont c WHERE a.grpcontno = b.grpcontno and c.PolicyNo = b.GrpContNo and a.GrpContNo = w.MissionProp1 AND a.state = '00' and w.ActivityID !='1800201005' union SELECT a.grpcontno, a.prtno, (SELECT codename from ldcode WHERE codetype = 'salechannel' AND code = a.agenttype), b.name, a.CValiDate, '',( SELECT codename FROM ldcode WHERE codetype = 'contstate' AND code = a.state),'', '', ( SELECT t.contplantype FROM lcproposal t WHERE t.grppropno = a.prtno), a.manageCom, c.AgentCode CustomerNo , a.agenttype,a.makedate FROM lcgrpcont a, lcgrpappnt b,LCAgentToCont c WHERE a.grpcontno = b.grpcontno and c.PolicyNo = b.GrpContNo AND a.state in (01,02)) g where 1=1 @{1} @{2} @{3} @{4} group by g.makedate desc,g.grpcontno ",clauses={
@SQL(value="select * from (select a.grpcontno,a.prtno,(select codename from ldcode where codetype = 'salechannel' AND code = a.agenttype),b.name,a.CValiDate,(SELECT f.activityname FROM lwactivity f WHERE f.ActivityID=w.ActivityID),( SELECT codename FROM ldcode where codetype = 'contstate' AND code = a.state),( SELECT sum(j.sumduepaymoney) FROM ljspay j where j.otherno = a.grpcontno AND j.paycount = '1' AND j.state = '2'),a.firstpaydate,( SELECT t.contplantype FROM lcproposal t WHERE t.grppropno = a.prtno), a.manageCom,c.AgentCode CustomerNo , a.agenttype,a.makedate from lcgrpcont a,lwmission w,lcgrpappnt b ,LCAgentToCont c WHERE a.grpcontno = b.grpcontno and c.PolicyNo = b.GrpContNo and a.GrpContNo = w.MissionProp1 AND a.state = '00' and w.ActivityID !='1800201005' union SELECT a.grpcontno, a.prtno, (SELECT codename from ldcode WHERE codetype = 'salechannel' AND code = a.agenttype), b.name, a.CValiDate, '',( SELECT codename FROM ldcode WHERE codetype = 'contstate' AND code = a.state),'', '', ( SELECT t.contplantype FROM lcproposal t WHERE t.grppropno = a.prtno), a.manageCom, c.AgentCode CustomerNo , a.agenttype,a.makedate FROM lcgrpcont a, lcgrpappnt b,LCAgentToCont c WHERE a.grpcontno = b.grpcontno and c.PolicyNo = b.GrpContNo AND a.state in (01,02)) g where 1=1 @{1} @{2} @{3} @{4} ",clauses={