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
相关文档:
曾经遇到这样的情况,在数据库的Meeting表中有PublishTime (DateTime,8)字段,用来存储一个开会时间,在存入时由于要指明开会具体时间,故格式为yyyy-mm-dd hh:mm:ss,而我们查询时是通过yyyy-mm-dd来进行的,即查询某一天的所有会议信息,这样如果通过select * from Meeting where PublishTime=@PublishTime (参数@PublishTime为y ......
1.SQL SERVER的数据类型
数据类弄是数据的一种属性,表示数据所表示信息的类型。任何一种计算机语言都定义了自己的数据类型。当然,不同的程序语言都具有不同的特点,所定义的数据类型的各类和名称都或多或少有些不同。SQLServer 提供了 25 种数据类型:
·Binary [(n)]
·Varbinary [(n)]
......
SqlServer 的性能比 Access 提高的不止一点了。
不过,科汛CMS的免费版带的是 Access 数据库。
有没有办法转成 mssql 的呢?当然可以
1, mssql中新建一张表,然后导入 access 里面的表和数据.
这个网上有方法,不多说了。
2, 修改 conn.asp 到 sql server 版本,这个也简单。
3, 浏览数据,直接就可以看 ......
在SQL SERVER 2005/2008中拥有一个对象
从SQL SERVER2000升级到2005/2008后,一个我们必须重新认识的情况是对象不再有所有者(owner)。架构包含对象,架构有所有者。如果你查询表sys.objects,你将会看到这看起来是正确的,只是表中还有一个字段principal_id,但是一般情况下它总是NULL值。不久前一天,我突然对principal ......
protected void Button1_Click(object sender, EventArgs e)
{
string strsql = "select * from TreeViewTemp where parentID=0";
DataTable dt = db.GetDataTable(strsql);
StringWriter sw = new StringWriter();
//StreamWriter sw = new Strea ......