case..when..then
来源:互联网 发布:qq飞车淘宝网商城 编辑:程序博客网 时间:2024/04/20 13:58
CASE是 SQL用来做为 if-then-else 之类逻辑的关键字。
//语法:
SELECT CASE ("栏位名")
FROM "表格名"
注:" 条件"
//例子:
//语句:select layername,case layertypewhen '点'then layerindex*2when '线'then layerindex*10else layerindexend newlayerindex,layerindexfrom th_geo_layerorder by layerindexasc
//结果:
//例子:古树名木按保护等级查询,保护等级的列表为汉字:一级,二级,三级
或者是:一级保护、二级保护、三级保护。(数据并不确定,故无法在控件中写死)。
//语句:string sSql = string.Format("select distinct ({0}) from {1} order by case when {0}='一级' then 1 when {0}='二级' then 2 when {0}='三级' then 3 else 1000 end",sFieldName,sTblName);
//结果:
//例子:古树名木按保护等级查询,保护等级的列表为汉字:一级,二级,三级
或者是:一级保护、二级保护、三级保护。(数据并不确定,故无法在控件中写死)。
//语句:string sSql = string.Format("select distinct ({0}) from {1} order by case when {0}='一级' then 1 when {0}='二级' then 2 when {0}='三级' then 3 else 1000 end",sFieldName,sTblName);
//结果:
//语句2:select distinct layertype fromth_geo_layer order by case layertype when '点' then 1when '线' then 2 when '面' then 3when '注记' then 4 else null end
//结果2:
- case when then else
- mssql ,case ,when,then
- case when then else
- case when then end
- CASE when then
- case when then
- sql --case when then
- case when then else
- case..when..then
- case when then
- case when then end
- CASE-WHEN-THEN
- sql case when then
- case when then else
- case when..then
- case when then
- oracle case when then
- oracle case when then
- android获取设备唯一标识完美解决方案
- 拼车
- MySQL数据库备份命令
- Android frame animation 实现 halo 效果
- mysql主从同步配置与不同步问题整理
- case..when..then
- 测试案例如何区分RAT,FAST,TOFT,FET
- 开启从Lotus 邮件系统到Exchange 系统的转移篇章-POC过程-迁移前准备工作!
- 查看mysql当前连接数
- 使用 rapidxml 做配置文件
- android Application Component研究之Activity(二)
- 《毛巾之战2:单片眼镜的命运 Towelfight 2: The Monocle of Destiny》游戏试玩测评
- IE下canvas使用问题归集
- 从JAVA多线程理解到集群分布式和网络设计的浅析