一条insert语句批量插入多条记录常见的insert语句,向数据库中,一条语句只能插入一条数据:insertintopersons(id_p,lastname,firstName,city)values(204,'haha','deng','shenzhen');(如上,仅插入了一条记录)怎样一次...
分类:
其他好文 时间:
2014-09-20 18:37:49
阅读次数:
273
select HSL.sortno, HSL.B, HSL.A, row_number() over(order by sortno desc) xh from (select t.B, t.A, case when t.B= '股份公司' then 9999999 else t.A end as....
分类:
数据库 时间:
2014-09-18 18:10:24
阅读次数:
216
SELECT r.industry_1,r.industry_2,r.agent_id,r.agent_name,COUNT(DISTINCT r.customer_name_a)数据总量,COUNT(DISTINCT CASE WHEN r.ifhs='Y' THEN r.customer_nam...
分类:
数据库 时间:
2014-09-18 12:52:53
阅读次数:
258
原文:03. 行列转换写法小结行列转换,通常有2种方法,一是CASE WHEN/UNION;一是PIVOT/UNPIVOT。对于行值或列数不固定的情况,需要用动态SQL。
一. 行转列 --drop table RowToCol
create table RowToCol
(
ID int,
Cod...
分类:
其他好文 时间:
2014-09-06 12:22:43
阅读次数:
209
CASE
在数据库中,对数据进行比对,
两种用法
第一种,不对任何列进行case 条件判断
SELECT Sid,English AS en, CASE WHEN English >=60 THEN '及格' WHEN English 60 THEN '英语及格' WHEN Math >60 THE...
分类:
数据库 时间:
2014-09-04 16:52:29
阅读次数:
286
适用sqlServer,oracleCASEWHEN 条件1 THEN 结果1WHEN 条件2 THEN 结果2WHEN 条件3 THEN 结果3WHEN 条件4 THEN 结果4.........WHEN 条件N THEN 结果NELSE 结果XENDCase具有两种格式。简单Case函数和Cas...
分类:
数据库 时间:
2014-09-04 09:37:27
阅读次数:
303
方法一:在sql中添加case when 实体和字段的映射 <resultMap?id="RM_PlanProjects"?type="cn.bidlink.yuecai.plan.model.PlanProjects">
?????????<result?property="disabled"?column="disabled"/>...
分类:
其他好文 时间:
2014-08-28 19:54:06
阅读次数:
313
根据上面的表信息输出下面的结果:
下面是建库和表结构据:
create table DeptSales
(
deptID int,
SubjMonth int ,
sales int ,
deptname varchar(50)
)
insert into deptsales (deptid ,subjmonth,sales) values (1,1,55);
in...
分类:
数据库 时间:
2014-08-26 17:21:36
阅读次数:
247
通过case when 进行自定义排序select * from (select a.c#,cname,case when score>=85 then '100-85' when score=70 then '85-70' ...
分类:
其他好文 时间:
2014-08-26 11:34:46
阅读次数:
188
CASE WHEN 条件1 THEN 结果1 WHEN 条件2 THEN 结果2 WHEN 条件3 THEN 结果3 WHEN 条件4 THEN 结果4......... WHEN 条件N THEN 结果N ELSE 结果XENDCase具有两种格式。简单Case...
分类:
数据库 时间:
2014-08-25 18:26:54
阅读次数:
181