摘要: http://www.cnblogs.com/wenjl520/archive/2008/12/03/1346401.html 阅读全文
posted @ 2011-04-17 19:16 cnby 阅读(266) 评论(0) 推荐(0) 编辑
摘要: grouping()函数:grouping(字段)=1则对字段进行了合计,grouping(字段)=0则此行没有对字段合计,根据这个特性我们可以控件要显示的统计列表,例子如下:View Code DROPTABLE[product]CREATETABLE[product]([proid][varchar](5)NULL,[in_date][varchar](10)NULL,[qty][int]NULL)INSERT[product]([proid],[in_date],[qty])VALUES('1','2004-1-2',10)INSERT[product]( 阅读全文
posted @ 2011-04-17 13:28 cnby 阅读(912) 评论(0) 推荐(1) 编辑
摘要: 例一:数据准备:View Code createtable#t(项目名称varchar(10),项目年度varchar(10),地市varchar(10),申请单位varchar(10),支持金额int)insert#tselect'名称1','2004','省直','1公司',400unionallselect'名称2','2004','省直','2公司',300unionallselect'名称3','2004','石家庄& 阅读全文
posted @ 2011-04-17 03:20 cnby 阅读(671) 评论(0) 推荐(0) 编辑
摘要: sql2005新特性,专为统计而用,直接给个实例吧。准备数据如下:View Code createtablestore(idintidentity(1,1),productidint,storeidchar(1),numint)insertstore(productid,storeid,num)select1,'A',6unionallselect1,'B',7unionallselect2,'A',8unionallselect2,'B',9cube,rollup与group up结合使用,两者的区别简单的就是:CUBE 生成的 阅读全文
posted @ 2011-04-17 01:55 cnby 阅读(578) 评论(0) 推荐(1) 编辑