SQL 条件语句
第一种:
SELECT
CASE
WHEN
price IS NULL THEN
'Not yet priced'
WHEN
price < 10 THEN
'Very Reasonable Title'
WHEN
price >= 10 AND
price < 20 THEN
'Coffee Table Title'
ELSE
'Expensive book!'
END
AS
"Price Category",
CONVERT(varchar(20), title) AS "Shortened Title"
from
pubs.dbo.titles
ORDER BY
price
第二种:
SELECT au_fname, au_lname,
CASE state
WHEN 'CA' THEN 'California'
WHEN 'KS' THEN 'Kansas'
WHEN 'TN' THEN 'Tennessee'
WHEN 'OR' THEN 'Oregon'
WHEN 'MI' THEN 'Michigan'
WHEN 'IN' THEN 'Indiana'
WHEN 'MD' THEN 'Maryland'
WHEN 'UT' THEN 'Utah'
END AS StateName
from pubs.dbo.authors
ORDER BY au_lname
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/hbzhangjian/archive/2006/07/31/1003684.aspx
SELECT top 2 id, uid,cn,
CASE len(cn)
WHEN 3 THEN 'California'
WHEN 2 THEN 'Kansas'
END AS StateName
from conf_users
相关文档:
SQLServer和Oracle的常用函数对比
1.绝对值
S:select abs(-1) value
O:select abs(-1) value from dual
2.取整(大)
S:select ceiling(-1.001) value
O:select ceil(-1.001) value from dual
3.取整(小)
S:select floor(-1.001) value
O:select floor(-1.001) value fr ......
SQL语句的优化就是将性能较低的SQL语句转换达成同样目的性能优异的SQL语句
下面我们一起来看看一些可以优化SQL的方法,希望大家多提出意见我们共同学习或者是大家有什么好的优化方法可以提出来共享一下。
第一种优化(使用指定列代替”*”)
使用“*”可以降低编写SQL语 ......
1.删除表
select 'drop table ' || table_name || ' purge;'
from user_tables
where length(table_name) <= 4;
删除带约束的表
Drop table 表名 cascade constraints;
2.查询view&同义词
--说明:可以根据视图的text_length ......
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
impo ......