找回密码
 注册账号

QQ登录

只需一步,快速开始

手机号码,快捷登录

手机号码,快捷登录

初学者课程:T3自学|T6自学|U8自学软件下载课件下载工具下载资料:通资料|U8资料|NC|培训|年结积分规则 | 使用常见问题Q&A
知识库:U8 | | NC | U9 | OA | 政务U8|U9|NCC|NC65|NC65客开|NCC客开新手必读 | 任务 | 快速增金币用友QQ群[微信群]
查看: 5614|回复: 8

[技巧] 使用Excel查询ERP数据库数据(Ms Query)之二

[复制链接]
发表于 2016-12-10 11:59:50 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册账号

×
销售等各部门需要及时查看ERP销售订单的执行情况——接单量、未发货情况等等数据,此需求可以使用excel查询ERP数据库(Ms Query)的功能解决!
代码见下:
ERP销售订单自动刷新表
版本1.1  销售订单主表
Select  so_somain.cSTCode "销售类型编码",so_somain.ID "销售订单主表标识",so_somain.cBusType "业务类型",so_somain.dDate "单据日期",so_somain.cSOCode "销售订单号",so_somain.cCusCode "客户编码",so_somain.cCusName "客户名称",so_somain.cDepCode "部门编码",so_somain.cPersonCode "业务员编码",so_somain.cexch_name "币种名称",so_somain.iExchRate "汇率",so_somain.iTaxRate "表头税率",so_somain.cMemo "备注",so_somain.cMaker "制单人",so_somain.cVerifier "审核人",so_somain.cCloser "关闭人",so_somain.dPreDateBT "预发货日期",so_somain.cCrmPersonCode "联系人编码",so_somain.cCrmPersonName "联系人"
From ufdata_001_2015.dbo.so_somain
版本1.2  销售订单子表
SELECT so_sodetails.cSOCode AS '销售订单号', so_sodetails.cInvCode AS '存货编码', inventory.cInvName AS '存货名称', so_sodetails.dPreDate AS '预发货日期', so_sodetails.iQuantity AS '数量', so_sodetails.iUnitPrice AS '原币无税单价', so_sodetails.iTaxUnitPrice AS '原币含税单价', so_sodetails.iMoney AS '原币无税金额', so_sodetails.iTax AS '原币税额', so_sodetails.iSum AS '原币价税合计', so_sodetails.iDisCount AS '原币折扣额', so_sodetails.iNatUnitPrice AS '本币无税单价', so_sodetails.iNatMoney AS '本币无税金额', so_sodetails.iNatTax AS '本币税额', so_sodetails.iNatSum AS '本币价税合计', so_sodetails.iNatDisCount AS '本币折扣额', so_sodetails.iFHQuantity AS '累计发货数量', so_sodetails.iFHMoney AS '累计原币发货金额', so_sodetails.iKPQuantity AS '累计开票数量', so_sodetails.iKPMoney AS '累计原币开票金额', so_sodetails.iTaxRate AS '税率', so_sodetails.cCusInvCode AS '客户存货编码', so_sodetails.cCusInvName AS '客户存货名称'
FROM ufdata_001_2015.dbo.inventory inventory, ufdata_001_2015.dbo.so_sodetails so_sodetails
WHERE so_sodetails.cInvCode = inventory.cInvCode
版本1.3  销售订单自动刷新表
SELECT so_somain.cSTCode AS '销售类型编码', so_somain.ID AS '销售订单主表标识', so_somain.cBusType AS '业务类型', so_somain.dDate AS '单据日期', so_somain.cSOCode AS '销售订单号', so_somain.cCusCode AS '客户编码', so_somain.cCusName AS '客户名称', so_somain.cDepCode AS '部门编码', so_somain.cPersonCode AS '业务员编码', so_somain.cexch_name AS '币种名称', so_somain.iExchRate AS '汇率', so_somain.iTaxRate AS '表头税率', so_somain.cMemo AS '备注', so_somain.cMaker AS '制单人', so_somain.cVerifier AS '审核人', so_somain.cCloser AS '关闭人', so_somain.dPreDateBT AS '预发货日期', so_somain.cCrmPersonCode AS '联系人编码', so_somain.cCrmPersonName AS '联系人', so_sodetails.cInvCode AS '存货编码', inventory.cInvName AS '存货名称', so_sodetails.dPreDate AS '预发货日期', so_sodetails.iQuantity AS '数量', so_sodetails.iUnitPrice AS '原币无税单价', so_sodetails.iTaxUnitPrice AS '原币含税单价', so_sodetails.iMoney AS '原币无税金额', so_sodetails.iTax AS '原币税额', so_sodetails.iSum AS '原币价税合计', so_sodetails.iDisCount AS '原币折扣额', so_sodetails.iNatUnitPrice AS '本币无税单价', so_sodetails.iNatMoney AS '本币无税金额', so_sodetails.iNatTax AS '本币税额', so_sodetails.iNatSum AS '本币价税合计', so_sodetails.iNatDisCount AS '本币折扣额', so_sodetails.iFHQuantity AS '累计发货数量', so_sodetails.iFHMoney AS '累计原币发货金额', so_sodetails.iKPQuantity AS '累计开票数量', so_sodetails.iKPMoney AS '累计原币开票金额', so_sodetails.iTaxRate AS '税率'
FROM ufdata_001_2015.dbo.inventory inventory, ufdata_001_2015.dbo.so_sodetails so_sodetails, ufdata_001_2015.dbo.so_somain so_somain
WHERE so_sodetails.cInvCode = inventory.cInvCode  and  so_somain.cSOCode = so_sodetails.cSOCode
版本1.4  销售订单自动刷新表
--添加排序
SELECT so_somain.cSTCode AS '销售类型编码', so_somain.ID AS '销售订单主表标识', so_somain.cBusType AS '业务类型', so_somain.dDate AS '单据日期', so_somain.cSOCode AS '销售订单号', so_somain.cCusCode AS '客户编码', so_somain.cCusName AS '客户名称', so_somain.cDepCode AS '部门编码', so_somain.cPersonCode AS '业务员编码', so_somain.cexch_name AS '币种名称', so_somain.iExchRate AS '汇率', so_somain.iTaxRate AS '表头税率', so_somain.cMemo AS '备注', so_somain.cMaker AS '制单人', so_somain.cVerifier AS '审核人', so_somain.cCloser AS '关闭人', so_somain.dPreDateBT AS '预发货日期', so_somain.cCrmPersonCode AS '联系人编码', so_somain.cCrmPersonName AS '联系人', so_sodetails.cInvCode AS '存货编码', inventory.cInvName AS '存货名称', so_sodetails.dPreDate AS '预发货日期', so_sodetails.iQuantity AS '数量', so_sodetails.iUnitPrice AS '原币无税单价', so_sodetails.iTaxUnitPrice AS '原币含税单价', so_sodetails.iMoney AS '原币无税金额', so_sodetails.iTax AS '原币税额', so_sodetails.iSum AS '原币价税合计', so_sodetails.iDisCount AS '原币折扣额', so_sodetails.iNatUnitPrice AS '本币无税单价', so_sodetails.iNatMoney AS '本币无税金额', so_sodetails.iNatTax AS '本币税额', so_sodetails.iNatSum AS '本币价税合计', so_sodetails.iNatDisCount AS '本币折扣额', so_sodetails.iFHQuantity AS '累计发货数量', so_sodetails.iFHMoney AS '累计原币发货金额', so_sodetails.iKPQuantity AS '累计开票数量', so_sodetails.iKPMoney AS '累计原币开票金额', so_sodetails.iTaxRate AS '税率'
FROM ufdata_001_2015.dbo.inventory inventory, ufdata_001_2015.dbo.so_sodetails so_sodetails, ufdata_001_2015.dbo.so_somain so_somain
WHERE so_sodetails.cInvCode = inventory.cInvCode AND so_somain.cSOCode = so_sodetails.cSOCode
order by so_somain.dDate
版本1.5  销售订单自动刷新表2016.11.01
--添加计算字段
SELECT so_somain.cSTCode AS '销售类型编码', so_somain.cBusType AS '业务类型', so_somain.dDate AS '单据日期', so_somain.cSOCode AS '销售订单号', so_somain.cCusCode AS '客户编码', so_somain.cCusName AS '客户名称', so_somain.cDepCode AS '部门编码', so_somain.cPersonCode AS '业务员编码', so_somain.cexch_name AS '币种名称', so_somain.iExchRate AS '汇率', so_somain.iTaxRate AS '表头税率', so_somain.cMemo AS '备注', so_somain.cMaker AS '制单人', so_somain.cVerifier AS '审核人', so_somain.cCloser AS '关闭人', so_somain.dPreDateBT AS '预发货日期', so_sodetails.dPreDate AS '预发货日期-01', so_somain.cCrmPersonCode AS '联系人编码', so_somain.cCrmPersonName AS '联系人', so_sodetails.cInvCode AS '存货编码', inventory.cInvName AS '存货名称', so_sodetails.iQuantity AS '数量', so_sodetails.iUnitPrice AS '原币无税单价', so_sodetails.iTaxUnitPrice AS '原币含税单价', so_sodetails.iMoney AS '原币无税金额', so_sodetails.iTax AS '原币税额', so_sodetails.iSum AS '原币价税合计', so_sodetails.iNatUnitPrice AS '本币无税单价', so_sodetails.iNatMoney AS '本币无税金额', so_sodetails.iNatTax AS '本币税额', so_sodetails.iNatSum AS '本币价税合计', so_sodetails.foutquantity AS '订单累计出库数量', (so_sodetails.iQuantity-isnull(so_sodetails.foutquantity,0)) AS '订单未出库数量', ((so_sodetails.iQuantity-isnull(so_sodetails.foutquantity,0))*so_sodetails.iNatUnitPrice) AS '订单未出库本币无税金额', so_sodetails.iKPQuantity AS '累计开票数量', so_sodetails.iKPMoney AS '累计原币开票金额', so_sodetails.iTaxRate AS '税率', (isnull(so_sodetails.foutquantity,0)-isnull(so_sodetails.iKPQuantity,0)) AS '已出库未开票数量', ((isnull(so_sodetails.foutquantity,0)-isnull(so_sodetails.iKPQuantity,0))*so_sodetails.iNatUnitPrice) AS '已出库未开票本币无税金额'
FROM ufdata_001_2015.dbo.inventory inventory, ufdata_001_2015.dbo.so_sodetails so_sodetails, ufdata_001_2015.dbo.so_somain so_somain
WHERE so_sodetails.cInvCode = inventory.cInvCode AND so_somain.cSOCode = so_sodetails.cSOCode
ORDER BY so_somain.dDate

发表于 2016-12-13 12:44:31 | 显示全部楼层
好好好!!!!!
回复 点赞 拍砖

使用道具 举报

发表于 2016-12-13 15:25:52 | 显示全部楼层
感谢楼主分享
回复 点赞 拍砖

使用道具 举报

发表于 2016-12-13 15:39:48 | 显示全部楼层
好东西谢谢
回复 点赞 拍砖

使用道具 举报

发表于 2016-12-16 11:12:20 | 显示全部楼层
真正的好东西啊
回复 点赞 拍砖

使用道具 举报

发表于 2017-5-9 14:38:12 | 显示全部楼层
好好好!!!!!
回复 点赞 拍砖

使用道具 举报

发表于 2017-9-22 15:00:44 | 显示全部楼层
好好好好好好
回复 点赞 拍砖

使用道具 举报

发表于 2023-4-24 14:08:08 | 显示全部楼层
好,很好,非常好,贼他妈好!!!!!
回复 点赞 拍砖

使用道具 举报

发表于 2023-4-28 15:11:47 | 显示全部楼层
这个的确是干货
回复 点赞 拍砖

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号

本版积分规则

QQ|站长微信|Archiver|手机版|小黑屋|用友之家 ( 蜀ICP备07505338号|51072502110008 )

GMT+8, 2024-11-23 18:25 , Processed in 0.079009 second(s), 10 queries , Gzip On, Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表