在SQL SERVER 2005/2008支持两种排名开窗函数和聚集开窗函数。以SQL SERVER中分面页为例,按时间顺序列出定单号。WITH OrderInfo AS(SELECT ROW_NUMBER() OVER(ORDER BY OrderDate) AS Number,OrderID,C...
分类:
数据库 时间:
2014-12-07 11:18:18
阅读次数:
183
--从table_name中随机取n行select top n * from table_name order by NEWID()
分类:
数据库 时间:
2014-12-06 21:25:47
阅读次数:
143
Given a sorted array of integers, find the starting and ending position of a given target value.
Your algorithm's runtime complexity must be in the order of O(log n).
If the target is not found in t...
分类:
其他好文 时间:
2014-12-06 08:53:46
阅读次数:
155
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
深搜+递归
/**
* Definition for binary tree
* public class TreeNode {
* int val;
* Tree...
分类:
其他好文 时间:
2014-12-05 17:34:59
阅读次数:
169
第一种方法效率最高
SELECT TOP 页大小 *
FROM
(
SELECT ROW_NUMBER() OVER (ORDER BY id) AS RowNumber,* FROM table1
) as A
WHERE RowNumber > 页大小*(页数-1)
注解:首先利用Row_number()为table1表的每一行添加一个行号,给行号这一列取名'RowN...
分类:
数据库 时间:
2014-12-05 17:23:42
阅读次数:
220
1. 建立 sequence? create sequence seq_img minvalue 1? maxvalue 21? start with 1? increment by 1? nocache nocycle? order; 2. 建立 sequence 之后, 第一次使用 ? ?sequence.currval 错误? SQL> s...
分类:
数据库 时间:
2014-12-05 15:42:34
阅读次数:
236
拓扑排序介绍拓扑排序(Topological Order)是指,将一个有向无环图(Directed Acyclic Graph简称DAG)进行排序进而得到一个有序的线性序列。这样说,可能理解起来比较抽象。下面通过简单的例子进行说明!例如,一个项目包括A、B、C、D四个子部分来完成,并且A依赖于B和D...
分类:
编程语言 时间:
2014-12-05 14:11:07
阅读次数:
295
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.
Here, we will use the integer...
分类:
其他好文 时间:
2014-12-05 12:46:33
阅读次数:
147
在写存储过程中有如下代码: FOR a IN ( SELECT a.svo_no,a.AUDIT_NO,a.order_id FROM TT_PI_MODEL_REL a ) LOOP SELECT COUNT(1) INTO V_FLAG...
分类:
数据库 时间:
2014-12-05 12:35:13
阅读次数:
234
SubsetsGiven a set of distinct integers,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must...
分类:
其他好文 时间:
2014-12-05 12:23:05
阅读次数:
145