狐表中的这个查询如何转换成 S QL 2005的语句
S ELECT Distinct {订单表}.[_Identify],{订单表}.订单表编号,{订单表}.分类,{订单表}.产品系列,{订单表}.成交日期,{订单表}.税piao,{订单表}.技术审核,{订单表}.财务审核,{订单表}.订单号,{订单表}.是否成交,{订单表}.客户代码,{订单表}.安排生产,
ISNULL((S elect SUM(ISNULL({订单明细}.订单金额,0)) From {订单明细} where {订单表}.订单表编号 = {订单明细}.订单表编号 And ({订单表}.技术审核 = 1 or {订单表}.财务审核 = 1 or {订单表}.是否成交 = '已成交')),0) as 订单金额,
isnull((S elect SUM(ISNULL({回款记录}.回款金额,0)) From {回款记录} where ({订单表}.订单表编号 = {回款记录}.订单表编号 And {回款}.流程进度 = '已审核')),0) as 回款金额 ,
ISNULL((S elect SUM(ISNULL({回款记录}.运费回款,0)) From {回款记录} where ({订单表}.订单表编号 = {回款记录}.订单表编号 And {回款}.流程进度 = '已审核')),0) as 运费回款 ,
isnull((S elect SUM(ISNULL({订单明细}.订单金额,0)) From {订单明细} where ({订单表}.订单表编号 = {订单明细}.订单表编号 And ({订单表}.技术审核 = 1 or {订单表}.财务审核 = 1 or {订单表}.是否成交 = '已成交'))),0) - isnull((S elect SUM(ISNULL({回款记录}.回款金额,0)) From {回款记录} where ({订单表}.订单表编号 = {回款记录}.订单表编号 And {回款}.流程进度 = '已审核')),0) As 未回金额,
ISNULL((S elect sum(ISNULL({发货记录}.运费,0)) From {发货记录} where ({订单表}.订单表编号 = {发货记录}.订单表编号 And {发货记录}.发货审核 = 1 And {发货记录}.运费结算方式 = '现付')),0) as 现付金额,
ISNULL((S elect sum(ISNULL({发货记录}.运费,0)) From {发货记录} where ({订单表}.订单表编号 = {发货记录}.订单表编号 And {发货记录}.发货审核 = 1 And {发货记录}.运费结算方式 = '垫付')),0) as 垫付金额,
ISNULL((S elect sum(ISNULL({发货记录}.运费,0)) From {发货记录} where ({订单表}.订单表编号 = {发货记录}.订单表编号 And {发货记录}.发货审核 = 1 And {发货记录}.运费结算方式 = '垫付')),0) - ISNULL((S elect SUM(ISNULL({回款记录}.运费回款,0)) From {回款记录} where ({订单表}.订单表编号 = {回款记录}.订单表编号 And {回款}.流程进度 = '已审核')),0) as 运费未回
FROM ((({订单表} LEFT JOIN {回款记录} ON {订单表}.订单表编号 = {回款记录}.订单表编号 )
LEFT JOIN {发货记录} ON {订单表}.订单表编号 = {发货记录}.订单表编号 )
LEFT JOIN {回款} ON {回款记录}.回款编号 = {回款}.回款编号 )
LEFT JOIN {订单明细} ON {订单表}.订单表编号 = {订单明细}.订单表编号
where ({订单表}.[技术审核] = 0 Or {订单表}.[财务审核] = 0 Or {订单表}.[安排生产] = 0
or isnull((S elect SUM(ISNULL({订单明细}.订单金额,0)) From {订单明细} where ({订单表}.订单表编号 = {订单明细}.订单表编号 And ({订单表}.技术审核 = 1 Or {订单表}.财务审核 = 1 Or {订单表}.是否成交 = '已成交'))),0) > isnull((S elect SUM(ISNULL({回款记录}.回款金额,0)) From {回款记录} where ({订单表}.订单表编号 = {回款记录}.订单表编号 And {回款}.流程进度 = '已审核')),0)
or ISNULL((S elect sum(ISNULL({发货记录}.运费,0)) From {发货记录} where ({订单表}.订单表编号 = {发货记录}.订单表编号 And {发货记录}.发货审核 = 1 And {发货记录}.运费结算方式 = '垫付')),0) > ISNULL((S elect SUM(ISNULL({回款记录}.运费回款,0)) From {回款记录} where ({订单表}.订单表编号 = {回款记录}.订单表编号 And {回款}.流程进度 = '已审核')),0)
) And {订单表}.[客户代码] = 'H Y-0008'