易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL聚合函


SQL聚合函
标签:sql聚合函数 杂谈 
 
聚合函数:
1.AVG 返回组中的平均值,空值将被忽略。
例如:use  northwind   // 操作northwind数据库
   Go
   Select  avg (unitprice)   //从表中选择求unitprice的平均值
      from  products
      Where  categoryid = ‘8’
2. BINABY_CHECKSUM  可用于检测表中行的更改
返回值由表达式的运算结果类型决定
例如:use northwind
             Go
      Create  table  tablebc(productid int,bchecksum int)   //建立有两个属性的表
      Insert  into tablebc   //向表中插入数据
          Select  priductid,binary_checksum(*)
          from  products
    Update  products   //更新
      Set  productname=’oishi tofu’, unitprice=20 where  productname = ‘tofu’
  
   Update  products   //更新
   Set  priductname=’oishi konbu’, unitprice = 5 where priductname=’konbu’
      Update priducts     //更新
   Set  prodctname=’oishi genen shouyu’, unitprice =12
           Where priductname=’genen shouyu’          
     Select  productid    //挑出变化的行
    from tablebc
    Where exists (
Select productid from products
Where  product.productid = tablebc.productid and
binary_checksu (*) <> tablebc.bchecksum)  //标志出变化的行
3.CHECKSUM


相关文档:

sql行转列


写一个存储过程,将表一按照表二的形式进行查询。
仓库名称 商品名称 数量
A
S001 12
A S002 17
A
S003 10
B S001 21
B
S002 5
B S003 ......

sql优化 对like ‘%xx%’ 的替换

在SQL中可以使用Like进行模糊查询,例如 f_stuname like 'a%' 查询f_stuname列以a开头的记录。
当我们在应用中使用
f_stuname
like '%a%' 时,如果

f_stuname有索引的话,这个索引也是不执行的
在SQL优化中这个写法就是一个不好的SQL了。
那么如何来替换这个呢,这一个就用到了Oracle的instr函数了
我们可以这样 ......

SQL Server 完美SPLIT函数


--
SQL Server Split函数
--
Author:zc_0101 
--
说明:
--
支持分割符多字节
--
使用方法 
--
Select * from DBO.F_SQLSERVER_SPLIT('1203401230105045','0')    
--
select * from DBO.F_SQLSERVER_SPLIT('abc1234a12348991234',' ......

sql 备忘

**************************************
****     sql  查询备忘                                   &nb ......

sql server 索引

sql server 创建索引
http://54laobaixing.blog.163.com/blog/static/57843681200952411133121/
SQL SERVER索引,优化
http://tieba.baidu.com/f?kz=170889655
Sybase SQL Server索引的使用和优化
http://www.yesky.com/79/211079.shtml ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号