Foxtable(狐表)用户栏目专家坐堂 → 求助 S QL 语句


  共有2151人关注过本帖树形打印复制链接

主题:求助 S QL 语句

帅哥哟,离线,有人找我吗?
111yangguojun
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:243 积分:1928 威望:0 精华:0 注册:2013/8/8 23:49:00
求助 S QL 语句  发帖心情 Post By:2017/2/17 13:27:00 [只看该作者]

狐表中的这个查询如何转换成  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'

 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/2/17 14:41:00 [只看该作者]

直接写有什么问题?报什么错?

 回到顶部