易截截图软件、单文件、免安装、纯绿色、仅160KB

SQL知识整理

一:Select语句:
       select 字段名 from 表名 where 条件 order by 排序
see:select distinct 从多个相同字段中抓唯一值    
see:查找ld_det_andy表中有数据但ld_det_temp表中没数据的数据
        select * from ld_det_andy a where
       (not exists (select * from ld_det_temp where ld_loc = a.ld_loc and ld_part = a.ld_part))
see:选出累计访问量最大的10个ip地址,并按访问量降序排列。
        select top 10 ip, countip from
       (select ip,count(*) as countip from records group by ip) a
       order by countip desc
see:表student(id,name,score)根据分数列(score)每10分为一段,查询每段分数的人数
        select ScoreRank,count(*) from
       (select ScoreRank = case
         when score >= 0   and score < 10   then '0-9'
         when score >= 10 and score < 20   then '10-19'
         when score >= 20 and score < 30   then '20-29'
         when score >= 30 and score < 40   then '30-39'
         when score >= 40 and score < 50   then '40-49'
         when score >= 50 and score < 60   then '50-59'
          when score >= 60 and score < 70   then '60-69'
         when score >= 70 and score < 80   then '70-79'
         when score >= 80 and score < 90   then '80-89'
  &nb


相关文档:

SQL Server 2005中新增的功能强大的窗口函数

原文地址:http://www.cnblogs.com/changhai0605/articles/1276319.html
Oracle的请参考:http://zonghl8006.blog.163.com/blog/static/4528311520083995931317/
1.简介:
SQL Server 2005中新增的窗口函数帮助你迅速查看不同级别的聚合,通过它可以非常方便地累计总数、移动平均值、以及执行其它计算。
窗口函数功能非 ......

sql 存储过程 分页

-- FUN:存储过程分页
-- @Table nvarchar(255), -- 表名
-- @Fields nvarchar(1000) = ' * ', -- 需要返回的列
-- @OrderField nvarchar(255), -- 排序的字段名,一般为唯一标识
-- @OrderType bit = 0, -- 设置排序类型, 非 0 值则降序
-- @PageSize int = 10, -- 每页有多少条记录
-- @PageIndex int = 1, -- 第 ......

一些基本的SQL命令

--显示版本号,当前日期
SELECT VERSION(),CURRENT_DATE(),NOW();
--免费的计算器
SELECT (20+5)*4 AS RESULT,SIN(PI()/3);
--创建数据库
CREATE DATABASE databasename;
--删除数据库
DROP DATABASE databasename;
--显示当前存在的数据库
SHOW DATABASES;
--选择数据库
USE ......

SQL Server 2005: Recursive Hierarchies to XML

Suppose we have a recursive hierarchy stored in a relational database and we want to write it to XML.  This might be for a variety of reasons – e.g. as a pre-cached input to a UI control, to export to another system using a pre-defined format, etc.
 
In SQL Server 2000, in order to ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号