- 浏览: 209139 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
q10000000:
你好 适用madMadia点击上传到服务器 没有反应啊LZ
在项目中整合FCKeditor文本编辑器 -
liweixxxx1990:
spring本版是3.0的(和版本也有关系吗?) 配置用到了s ...
struts2+spring发送mail -
floger:
liweixxxx1990 写道我照着你这个写的出现了下面的错 ...
struts2+spring发送mail -
liweixxxx1990:
我照着你这个写的出现了下面的错误,怎么解决啊??:Messag ...
struts2+spring发送mail -
jueyue:
不错,把问题解决了
Myeclipse下java.lang.OutOfMemoryError: Java heap space的解决
复杂年月处理.sql
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->--定义基本数字表 declare @T1 table(代码 int,名称 varchar(10),参加时间 datetime,终止时间 datetime) insert into @T1 select 12,'单位1','2003/04/01','2004/05/01' union all select 22,'单位2','2001/02/01','2003/02/01' union all select 42,'单位3','2000/04/01','2003/05/01' union all select 25,'单位5','2003/04/01','2003/05/01' --定义年表 declare @NB table(代码 int,名称 varchar(10),年份 int) insert into @NB select 12,'单位1',2003 union all select 12,'单位1',2004 union all select 22,'单位2',2001 union all select 22,'单位2',2002 union all select 22,'单位2',2003 --定义月表 declare @YB table(代码 int,名称 varchar(10),年份 int,月份 varchar(2)) insert into @YB select 12,'单位1',2003,'04' union all select 22,'单位2',2001,'01' union all select 22,'单位2',2001,'12' --为年表+月表数据处理准备临时表 select top 8246 y=identity(int,1753,1) into #tby from (select id from syscolumns) a, (select id from syscolumns) b, (select id from syscolumns) c --为月表数据处理准备临时表 select top 12 m=identity(int,1,1) into #tbm from syscolumns /*--数据处理--*/ --年表数据处理 select a.* from( select a.代码,a.名称,年份=b.y from @T1 a,#tby b where b.y between year(参加时间) and year(终止时间) ) a left join @NB b on a.代码=b.代码 and a.年份=b.年份 where b.代码 is null --月表数据处理 select a.* from( select a.代码,a.名称,年份=b.y,月份=right('00'+cast(c.m as varchar),2) from @T1 a,#tby b,#tbm c where b.y*100+c.m between convert(varchar(6),参加时间,112) and convert(varchar(6),终止时间,112) ) a left join @YB b on a.代码=b.代码 and a.年份=b.年份 and a.月份=b.月份 where b.代码 is null order by a.代码,a.名称,a.年份,a.月份 --删除数据处理临时表 drop table #tby,#tbm
交叉表.sql
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->--示例 --示例数据 create table tb(ID int,Time datetime) insert tb select 1,'2005/01/24 16:20' union all select 2,'2005/01/23 22:45' union all select 3,'2005/01/23 0:30' union all select 4,'2005/01/21 4:28' union all select 5,'2005/01/20 13:22' union all select 6,'2005/01/19 20:30' union all select 7,'2005/01/19 18:23' union all select 8,'2005/01/18 9:14' union all select 9,'2005/01/18 18:04' go --查询处理: select case when grouping(b.Time)=1 then 'Total' else b.Time end, [Mon]=sum(case a.week when 1 then 1 else 0 end), [Tue]=sum(case a.week when 2 then 1 else 0 end), [Wed]=sum(case a.week when 3 then 1 else 0 end), [Thu]=sum(case a.week when 4 then 1 else 0 end), [Fri]=sum(case a.week when 5 then 1 else 0 end), [Sat]=sum(case a.week when 6 then 1 else 0 end), [Sun]=sum(case a.week when 0 then 1 else 0 end), [Total]=count(a.week) from( select Time=convert(char(5),dateadd(hour,-1,Time),108) --时间交界点是1am,所以减1小时,避免进行跨天处理 ,week=(@@datefirst+datepart(weekday,Time)-1)%7 --考虑@@datefirst对datepart的影响 from tb )a right join( select id=1,a='16:00',b='19:59',Time='[5pm - 9pm)' union all select id=2,a='20:00',b='23:59',Time='[9pm - 1am)' union all select id=3,a='00:00',b='02:59',Time='[1am - 4am)' union all select id=4,a='03:00',b='07:29',Time='[4am - 8:30am)' union all select id=5,a='07:30',b='11:59',Time='[8:30am - 1pm)' union all select id=6,a='12:00',b='15:59',Time='[1pm - 5pm)' )b on a.Time>=b.a and a.Time<b.b group by b.id,b.Time with rollup having grouping(b.Time)=0 or grouping(b.id)=1 go --删除测试 drop table tb /*--测试结果 Mon Tue Wed Thu Fri Sat Sun Total -------------- ----- ----- ----- ----- ----- ------ ---- ------- [5pm - 9pm) 0 1 2 0 0 0 0 3 [9pm - 1am) 0 0 0 0 0 0 2 2 [1am - 4am) 0 0 0 0 0 0 0 0 [4am - 8:30am) 0 0 0 0 1 0 0 1 [8:30am - 1pm) 0 1 0 0 0 0 0 1 [1pm - 5pm) 1 0 0 1 0 0 0 2 Total 1 2 2 1 1 0 2 9 (所影响的行数为 7 行) --*/
任意两个时间之间的星期几的次数-横.sql
<!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[f_weekdaycount]') and xtype in (N'FN', N'IF', N'TF')) drop function [dbo].[f_weekdaycount] GO /*--计算任意两个时间之间的星期几的次数(横向显示) 本方法直接判断 @@datefirst 做对应处理 不受 sp_language 及 set datefirst 的影响 --邹建 2004.08(引用请保留此信息)--*/ /*--调用示例 select * from f_weekdaycount('2004-9-01','2004-9-02') --*/ create function f_weekdaycount( @dt_begin datetime, @dt_end datetime )returns table as return( select 跨周数 ,周一=case a when -1 then case when 1 between b and c then 1 else 0 end when 0 then case when b<=1 then 1 else 0 end +case when c>=1 then 1 else 0 end else a+case when b<=1 then 1 else 0 end +case when c>=1 then 1 else 0 end end ,周二=case a when -1 then case when 2 between b and c then 1 else 0 end when 0 then case when b<=2 then 1 else 0 end +case when c>=2 then 1 else 0 end else a+case when b<=2 then 1 else 0 end +case when c>=2 then 1 else 0 end end ,周三=case a when -1 then case when 3 between b and c then 1 else 0 end when 0 then case when b<=3 then 1 else 0 end +case when c>=3 then 1 else 0 end else a+case when b<=3 then 1 else 0 end +case when c>=3 then 1 else 0 end end ,周四=case a when -1 then case when 4 between b and c then 1 else 0 end when 0 then case when b<=4 then 1 else 0 end +case when c>=4 then 1 else 0 end else a+case when b<=4 then 1 else 0 end +case when c>=font-weight: bold; color: #8发表评论
-
SQL语句大全 (转)
2011-05-16 13:42 1201原文地址:http://topic.csdn.net/u/20 ... -
(转)SQL 查询效率
2011-04-25 09:36 956很多人不知道SQL语句 ... -
数据库索引 类型 (转载)
2010-10-13 09:02 953http://www.zoomhoo.com/viewthre ... -
索引的优点和缺点,设计数据库的人员必看--转载
2010-10-13 09:00 963一、为什么要创建索引 ... -
破解 sql prompt 4 的方法
2010-03-31 10:58 45041.首先安装sql prompt 的原文件 ... -
Managing Hierarchical Data in MySQL(转)
2010-03-11 10:17 944转:http://dev.mysql.com/tech-r ... -
java web和servlet结合使用为数据库备份
2009-09-21 09:41 1108使用Runtime类的方法备份数据库和web下载结合起来 ... -
存储过程的使用
2009-09-16 08:28 630=================分页========= ... -
oracle常用函数3
2009-09-16 08:26 790105。STDDEV_POP 功能描 ... -
oracle常用函数
2009-09-16 08:20 6821. ASCII 返回与指定的字符对应的十进制数; ... -
sql强人使用数据库计算身份证算法
2009-07-14 09:43 1084一、 --SQL SERVER 15位身 ... -
sql的大全代码(7)
2009-04-17 12:14 850各种字符串合并处理示例.sql SQL code & ... -
sql的大全代码(6)
2009-04-17 12:13 727统计--交叉表+日期+优先.sql SQL code ... -
sql的大全代码(4)
2009-04-17 12:11 970工作日处理函数(标准节假日).sql SQL code ... -
sql的大全代码(3)
2009-04-17 12:10 786特殊日期加减函数.sql SQL code < ... -
sql的大全代码(2)
2009-04-17 12:09 799CONVERT在日期转换中的使用示例.sql: SQL c ... -
sql的大全代码(1)
2009-04-17 12:08 1048设置内存选项: SQL code <!-- ... -
SQL命令大全-中英文对照
2009-03-24 15:03 2031--语 句 功 能 --数据操作 SELECT --从数据库表 ...
相关推荐
SQL Server错误代码大全
这是经过整理和测试的,最新ASP通用防SQL注入代码。 很简洁也很好用.和大家分享.
SQL防注入代码SQL防注入代码SQL防注入代码SQL防注入代码SQL防注入代码SQL防注入代码
1、本地执行代码生成工具,可生成controller、service、...3、可按照资源中提供的建表sql导入到数据库,然后双加start.bat,即可在上方配置的outdir目录中找到生成的代码 4、复制代码到项目目录修修改改即可使用
比较全面的SQL大全,在该文档中对SQL语句做了详细的讲述
SQL代码 sql练习,很多sql相关的练习,可以参考学习下,对pl/sql有帮助
SQL进阶教程(MICK (作者) 吴炎昌 (译者)) ,随书sql代码.本书是《SQL基础教程》作者MICK为志在向中级进阶的数据库工程师编写的一本SQL技能提升指南。全书可分为两部分,第一部分介绍了SQL语言不同寻常的使用技巧,...
pl/sql例题代码pl/sql例题代码pl/sql例题代码
完美的SQL语句大全供我们参考使用,sql的专业分享
sql 代码生成器,常用生成,语法,帮助!
这里面整理了很多经常用到的SQL查询代码案例。能够有效的帮助你在学习数据库部分的SQL查询这块的需求。
精心编写的”SQL Server 2005代码大全“,仅将此分享给所有的数据库开发爱好者!
精心收集了很多常用的经典的SQL功能代码。绝对的是经典~~~~
收集汇总了设计者在SQL 编程中所有出现的错误代码提示大全 希望对大家有所帮助
好用的SQL Server代码格式化插件,有代码提示等功能
SQL数据库代码集合
程序员SQL语句大全大全(经典珍藏版)
适合新手入门,一切都是熟能生巧,练熟这些代码,可以基本掌握SQL sever
Sqlserver代码提示工具,提示表结构信息,快速书写标准的SQL
ASP防SQL注入代码,集合了最新的代码。