易截截图软件、单文件、免安装、纯绿色、仅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:1999连接

SQL:1999连接
SQL:1999连接在语法上和传统的ORACLE连接有着很大的不同。SQL:1999连接的类型在from语句中指明。ORACLE 9I支持的SQL:1999连接包括:
l         CROSS连接
l         NATURAL连接
l       ......

SQL脚本字段[content]和content区别

      今天我在SQL Server 2005中用脚本创建一张表,查资料发现有的脚本中字段有加[]中符号,我问了冬季,得知是这回事,用[]的字段名,即便是sql关键字也可以作为字段名,不会报错。
      SQL Server里的表中添加一个字段,如:time系统会自动加一对方括号即:[time] ......

在VB2008 速成版中使用参数化SQL查询语句无效

  最近刚学会在VB2008 中使用参数化SQL语句,于是马上用到代码中,却碰到查不到任何数据的情况,纠结了好几天,还是没有搞明白,差点吐血。不得已还是先在代码中使用字符串拼接的SQL语句。
  包含参数化SQL语句的代码如下:
            Dim cmSl As N ......

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号