对pl/sql 语句的优化(上集)
对这个进行优化
select n5001 门店,n5002 部门,n5004 小分类,n5019 商品编码,c01d21 商品名称,
nvl(xse,0)-nvl(dzxs,0) 销售,
mle 毛利,
nvl(xl,0)-nvl(dzsl,0) 销量
from
(select n5001,n5002,n5004,n5019,sum(n5011) xse,sum(n5016) mle,sum(n5023) xl
from n50
where to_char(n5010,'yyyymmdd')>='20100401'
and to_char(n5010,'yyyymmdd')<='20100431'
group by n5001,n5002,n5004,n5019),
(select g08,g09,g02,sum(g03*g07) dzxs,sum(G03) dzsl from batchgoods
where to_char(g04,'yyyymmdd')>='20100401'
and to_char(g04,'yyyymmdd')<='20100431'
group by g08,g09,g02),c01d
where n5001=g08(+)
and n5019=g02(+)
and n5001=c01d00(+)
and n5019=c01d01(+)
执行计划
SELECT STATEMENT, GOAL = CHOOSE Cost=10060 Cardinality=3931 Bytes=475651
MERGE JOIN OUTER Cost=10060 Cardinality=3931 Bytes=475651
SORT JOIN Cost=8063 Cardinality=3931 Bytes=338066
NESTED LOOPS OUTER Cost=7952 Cardinality=3931 Bytes=338066
VIEW Object owner=FZDC Cost=4015 Cardinality=3931 Bytes=239791
SORT GROUP BY Cost=4015 Cardinality=3931 Bytes=149378
TABLE ACCESS FULL Object owner=FZDC Object name=N50 Cost=3955 Cardinality=3931 Bytes=149378
TABLE ACCESS BY INDEX ROWID Object owner=FZDC Object name=C01D  
相关文档:
1. 安装oracle 10G客户端
要访问oracle数据库必须安装oracle客户端。安装oracle客户端有两种方式,即完整安装和立即安装,这两种方式都可以。安装完后配置要链接数据库服务器。
$ORACLE_HOME\network\admin\tnsname.ora
在此配置文件里添加如下内容:
sunora =
(DESCRIPTION =
......
随着Visual Studio 2010的发布,Microsoft SQL Server Compact 3.5也升级为Microsoft
SQL Server Compact SP2。
下载地址如下:
SQL
Server Compact 3.5 SP2 for Windows mobile devices (all platforms &
processors)
SQL
Server Compact 3.5 SP2 for Windows desktop (32-bit and 64-bit)
  ......
--该表保存结果
create table c(c1 tinyint, c2 tinyint, c3 tinyint, c4 tinyint, c5 tinyint, c6 tinyint, c7 tinyint, c8 tinyint, c9 tinyint, c10 tinyint, c11 tinyint, c12 tinyint, c13 tinyint, c14 tinyint, c15 tinyint, c16 tinyint, c17 tinyint, c18 tinyint, c19 tinyint, c20 tinyint, c21 tinyint, c22 t ......
Access 的 SQL 中,计算相应编号的记录之间 加 减 的查询命令
例如 计算ID为 6 的 合计 减去 ID 为 2、3、4 以及加上 ID 为 5 的合计
SELECT SUM(R) AS 结果
from
(
SELECT 合计 AS R from T1 WHERE (ID = 6) UNION
SELECT -合计 AS R from T1 WHERE (ID = 2) UNION
SELECT -合计 AS R f ......
一、基础
1、说明:创建数据库
CREATE DATABASE database-name
2、说明:删除数据库
drop database dbname
3、说明:备份sql server
--- 创建 备份数据的 device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\mssql7backup\MyNwind_1.dat'
--- 开始 备份
BACKUP DATABASE pubs TO testBack
4、说 ......