SQL learning
Five basic search conditions are summarized here:
1) Comparison test
2) Range test
3) Set membership test
4) Pattern matching test (Like)
The pattern matching test checks to see whether the data value in a column matches a specified pattern
% mathes any sequence of zero or more characters.
_ matches any single character.
// Find products whose product IDs start with the four letters "A%BC"
SELECT order_num ,product
from orders
WHERE product LIKE 'A$%BC' ESCAPE '$' ;
5) Null value test (IS NULL)
In SQL's three-valued logic, a search condition can yield a TRUE,FALSE, or NULL result. Only rows where search codition yields a TRUE result are included in the query result.
Rules For Single-Table Query Processing
The from clause is applied first; the where clause is applied next ; the SELECT clause is applied next . Finally, the
ORDER BY clause is applied to sort the query results.
相关文档:
在sql查询分析器里面是不能直接运行cmd命令的
但是SQL给出了一个接口
--打开高级设置
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
--打开xp_cmdshell扩展存储过程
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE
首先 打开一些配置
然后执行你要运行cmd命令
exec master..xp_cmdshell 'net star ......
-- create by zh
-- n 是作物的时间,x 是希望在几点成熟,返回播种的时间
with t as
(
select 64 n,9 x from dual union all
select 64 n,13 x from dual union all
select 64 n,17 x from dual union all
select 64 n,20 x from dual
)
select '成熟时间:' || lpad(to_char(n),4,' ' ......
基于msdn 详细学习T-SQL (http://msdn.microsoft.com/zh-cn/library/bb510741.aspx)
Aggregate function--Sum() Two Sample from msdn
USE AdventureWorks;
GO
SELECT Color, SUM(ListPrice), SUM(StandardCost)
from Production.Product
WHERE Color IS NOT NULL
AND ListPrice != 0.00 ......