首先建立一个表如下: ======================= BirthDay datetime not null Age 通过公式计算得出 ======================= 以上是表的两个字段,通过BirthDay字段的数据自动生成Age字段 Age字段的公式如下: (case when (datediff(year,[BirthDay],getdate()) <> 0) then (ltrim(datediff(year,[BirthDay],getdate()))
select a.*,b.item_name from (select sum(buy_num) num,nqh from (select substr(a.embed_dis_province,1,10) dtime,b.buy_num,case substr(a.idcardcode,1,2) when '11' then '1100' when '12' then '1200' when '31' then '3100' when '50' then '5000' else substr(
SQL加.查.改.删.函数 USE lianxiGOcreate table student1(code int not null ,name varchar(20),sex char(4),cid int not null,yufen decimal(20,2),shufen decimal(20,2),yingfen decimal(20,2),banji varchar(10),dizhi varchar(10),age int,)--添加信息insert into student1
原文:SQL Server 日期相关 原帖出处:http://blog.csdn.net/dba_huangzj/article/details/7657979 对于开发人员来说,日期处理或许简单,或许很难.结合自己过往的开发经验并整合网上的例子,总结出一些日期相关的操作,供自己备用及为大家分享: 一.日期类型: 对于SQL Server 2008 来说(因为2000甚至2005已经稍微有被淘汰的迹象,所以在此不作过多说明,加上自己工作使用的是2008R2.所以不保证08以前的能用),日期类型有
SQL 语句日期用法及函数 --DAY().MONTH().YEAR()——返回指定日期的天数.月数.年数:select day(cl_s_time) as '日' from class --返回天select '月'=month(cl_s_time) from class --返回月select '年'=year(cl_s_time) from class --返回年 --DATEADD(datepart,number,date)——在日期上增加给定日期类型的数量:select date
/* 1.是否以某字符串结尾 endsWith(theStr,endStr) @param theStr:要判断的字符串 @param endStr:以此字符串结尾 @return boolean; */ function endsWith(theStr,endStr) { var theStrLength=theStr.length; var endStrLength=endStr.length; var theStrEnd=theStr.substring(theStrLength-endS