一.简述 在操作数据库的过程经常忘了case关键字的语法,所以在此记录一下. 二.内容 case的简单语法 SELECT testName, testSex, CASE testSex WHEN '1' THEN '男' WHEN '0' THEN '女' END Sex FROM testDataTable SELECT testName, testDatetime, CASE WHEN testDatetime < '2016-04-11' THEN 'old' ELSE 'new' END
over不能单独使用,要和分析函数:rank(),dense_rank(),row_number()等一起使用.其参数:over(partition by columnname1 order by columnname2)含义:按columname1指定的字段进行分组排序,或者说按字段columnname1的值进行分组排序.例如:employees表中,有两个部门的记录:department_id =10和20select department_id,rank() over(partition
Select * from [DBData].[dbo].[T_Student] where Name='lilei' 查询结果如下: 结论:由查询结果可知 SQL Server 默认是不区分大小写的. Select * from [DBData].[dbo].[T_Student] where Name like '%(%' COLLATE chinese_prc_CS_AI_WS 查询结果如下: 排序规则名称由两部份构成,前半部份是指本排序规则所支持的字符集.如: Chinese_PRC_C
今天再开发中遇到一个需求 ,需要查处某某年某月某日 到 某某年某月某日时间段的数据! 看到之前框架里有用到between,今天果断用了一下!效果不错! 实现代码: $where .=" start_time between '".$create_time[0]."' and '".$create_time[1]."' and end_time between '".$create_time[0]."' and '".$crea
mysql如何要删除一个一行或者多行,用sql语句delete关键词,固定用法 delete from 表名. 1,delete删除一行 delete from student where id=1 2,delete删除多行 delete from student where in (1,2,3) 3,删除表的所有数据 delete from student 请使用不带where子句的delete语句 文章来自 http://www.dc3688.com 原文地址:http://blog.51c
SELECT a.managecom, a.subtype, count(*) loadsucc, sum(case when a.state in ('4', '5', '6', '7', '8', '9') then 1 else 0 end) recogsucc, sum(case when a.state in ('3', '12', '13') then 1 else 0 end) recogfail, sum(case when a.state in ('1', '2') then