




已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
sybase时间函数默认分类 2008-12-17 09:19 阅读305评论0 字号: 大大 中中 小小 日期函数getdate()得到当前时间,可以设置得到各种时间格式.datepart(日期部分,日期)取指定时间的某一个部分,年月天时分秒.datediff(日期部分,日期1,日期2)计算指定的日期1和日期2的时间差多少.dateadd(日期部分,数值表达式,日期)计算指定时间,再加上表达式指定的时间长度.-取时间的某一个部分select datepart(yy,getdate() -yearselect datepart(mm,getdate() -monthselect datepart(dd,getdate() -dayselect datepart(hh,getdate() -hourselect datepart(mi,getdate() -minselect datepart(ss,getdate() -sec-取星期几set datefirst 1select datepart(weekday,getdate() -weekday-字符串时间select getdate() - 03/11/12select convert(char,getdate(),101) - 09/27/2003select convert(char,getdate(),102) - 2003.11.12select convert(char,getdate(),103) - 27/09/2003select convert(char,getdate(),104) - 27.09.2003select convert(char,getdate(),105) - 27-09-2003select convert(char,getdate(),106) - 27 Sep 2003select convert(char,getdate(),107) -Sep 27, 2003select convert(char,getdate(),108) -11:16:06select convert(char,getdate(),109) -Sep 27 2003 11:16:28:746AMselect convert(char,getdate(),110) -09-27-2003select convert(char,getdate(),111) -2003/09/27select convert(char,getdate(),112) -20030927select rtrim(convert(char,getdate(),102)+ +(convert(char,getdate(),108) - 2003.11.12 11:03:41-整数时间select convert(int,convert(char(10),getdate(),112) - 20031112select datepart(hh,getdate()*10000 + datepart(mi,getdate()*100 + datepart(ss,getdate() - 110646-时间格式 YYYY.MM.DD HH:MI:SS 转换为 YYYYMMDDHHMISSdeclare a datetime,tmp varchar(20),tmp1 varchar(20)select a=convert(datetime,2004.08.03 12:12:12)select tmp=convert(char(10),a,112)select tmpselect tmp1=convert(char(10),datepart(hh,a)*10000 + datepart(mi,a)*100 + datepart(ss,a)select tmp1select tmp=tmp+tmp1select tmp-当月最后一天declaretmpstr varchar(10)mm int,premm int,curmmlastday varchar(10)beginselect mm=datepart(month,getdate()-当月select premm=datepart(month,dateadd(month,-1,getdate() -上个月if (mm=1 and mm=9 and mm=11)select tmpstr=convert(char(4),datepart(year,getdate()+.+convert(char(2),datepart(month,dateadd(month,1,getdate()+.+01elseselect tmpstr=convert(char(4),datepart(year,dateadd(year,1,getdate()+.0+convert(char(1),datepart(month,dateadd(month,1,getdate()+.+01select curmmlastday=convert(char(10),dateadd(day,-1,tmpstr),102) -当月最后一天end教你快速掌握Sybase IQ常用分析型函数来源:赛迪网 编辑:若水 时间:2008-04-22 46 . 很多人都知道,Sybase IQ是高性能的数据仓库引擎,在SQL编程方面,它也引入了许多新的特性,分析型函数就是其中之一。常用的分析型函数如下:Grouping( ), Variance( ),StdDev( ), Rank( ), Dense_Rank( ),Percentile_Disc( ), Percentile_Count( ), Ntile( )等。 在实际的工作和学习中,使用以上的分析型函数,可以为用户的前端编程或者后台SQL编程带来极大的方便。 以上函数的简单示例如下: select top 10 taxpayercode ,sum(mny_seze) as mny_seze_sukm, sum(mny_srze) as mny_srze_sum, DENSE_RANK() over( order by mny_srze_sum desc) as rank_all from tqa_f_nsrqusb where id_mth=200702 group by taxpayercode order by rank_all select taxpayercode ,sum(mny_seze) as mny_seze_sukm,sum(mny_srze) as mny_srze_sum from tqa_f_nsrqusb where id_mth=200702 group by taxpayercode order by mny_srze_sum desc select top 10 taxpayercode ,sum(seze) as seze , NTILE(2) over ( order by seze desc) as ntile from whtaxpayertaxbook where yr_sb=2005 and mth_sb=1 group by taxpayercode order by seze select top 10 taxpayercode, sum(seze) as seze, percent_rank() over (order by seze desc) as per_rank from whtaxpayertaxbook where yr_sb=2005 and mth_sb=1 group by taxpayercode order by seze select top 10 taxpayercode, sum(seze) as seze, rank(
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025员工试用期劳动合同范本AA
- 户外摆件租赁合同范本
- 房顶漏水装修合同范本
- 种植用工合同范本
- 酒店的购销合同范本
- 厂家授权合作合同范本
- 2025合同范本汇编大全
- 快递店员工合同范本
- 拍车定金合同范本
- 2025关于石油购销的合同范本
- (2025)工会知识竞赛题库含参考答案
- 企业员工激励奖励制度完整方案
- 2025医学基础知识试题(附答案)
- 2025年江苏省高考政治试题与参考答案
- 客户项目管理办法
- 西藏建筑业用工合同范本
- 软件项目需求调研报告样例
- 楼层封顶仪式活动方案
- 湖北省武汉市硚口区2024-2025学年八年级下学期数学期末试题(含答案)
- 2025年猫砂项目可行性研究报告
- 收纳师培训课件下载
评论
0/150
提交评论