这是查询语句:
1。select
convert(char(12),a.settle_date,100) 'settlementdate'
from ldb174.settlement a,
ldb174.opsactivity c,
ldb174.transportation d
where 1=1
and c.settle_id is not null
and c.opsactivityid =
psactivityid
and c.settle_id = a.settle_id
and d.trnsp_code =* a.trnsp_code
2。
select
df.commodityalias 'commodity'
,pricesource
,df.marketregionalias 'marketregion'
,c.commoditydescription 'commoditydes'
,datetype
,m.name 'monthname'
,isnull(daysbefore,0) 'daysbefore'
,basisnonpriceoption 'nonprice'
,isnull(daysafter,0) 'daysafter'
,dateadd(dd,-daysbefore,basisdate) 'fromdate'
,dateadd(dd,daysafter,basisdate) 'todate'
,basisdate 'basisdate'
,day(dateadd(dd,-daysbefore,basisdate)) 'startday'
from
ldb174.deal_formula df,
ldb174.commodity c,
ldb174.month m
where 1=1
and df.commodityalias = c.commodityalias
and df.deal = :deal
and df.deal_seq = :deal_seq
and df.frml_type = 'DEAL'
and df.cont_mth = m.num
order by
df.frml_seq
3。
select
c.deliveryalias
,a.specificationtext 'spectext'
,da.clausedesc 'paymentdesc'
,da.clausetext 'payterms'
,db.clausetext 'genprov'
,dc.clausetext 'deliverytext'
,dd.clausetext 'tolerance'
,di.clausetext 'inspectcost'
from ldb174.commodity a
,ldb174.deal_master b
,ldb174.deal_detail c
,ldb174.vessel vs
,ldb174.clause da
,ldb174.clause db
,ldb174.clause dc
,ldb174.clause dd
,ldb174.clause di
where 1 = 1
and c.deal = :deal
and c.deal = b.deal
and c.deal_seq = :deal_seq
and a.commodityalias = c.commodityalias
and da.clausetype = 'PAYMENT'
and db.clausetype = 'PROVISN'
and dc.clausetype = 'DELIVERY'
and dd.clausetype = 'TOLERANC'
and di.clausetype = 'INSPECT'
and da.clausealias =* b.paymentalias
and db.clausealias =* b.provisionalias
and dc.clausealias =* c.deliveryalias
and di.clausealias =* b.inspectionalias
按照1,2,3的顺序执行就不会有问题,其他的顺序就会出现CUP100%的占有率。