今天跟大家分享一下mongodb中比较好玩的知识,主要包括:聚合,游标。一: 聚合 常见的聚合操作跟sql server一样,有:count,distinct,group,mapReduce。 count count是最简单,最容易,也是最常用的聚合工具,它的使用跟我们C#里面的count...
分类:
数据库 时间:
2014-12-25 20:04:48
阅读次数:
163
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.
For example,
Given 1->2->3->3->4->4->5, return 1->2->5.
Given 1->1-...
分类:
其他好文 时间:
2014-12-24 21:32:51
阅读次数:
214
1 SELECT * from new; 2 SELECT stuname FROM new; //查询某一列 3 SELECT DISTINCT stuname FROM new; ...
分类:
数据库 时间:
2014-12-24 17:35:53
阅读次数:
137
1、查询去重数据select *, count(distinct name) from table group by name2.避免重复数据如果是用主键primary或者唯一索引unique区分了记录的唯一性,避免重复插入记录可以使用:insertignoreinto table_name(ema...
分类:
数据库 时间:
2014-12-24 13:23:50
阅读次数:
156
Given n distinct positive integers, integer k (k i) d[i][j][v] += d[i][j-1][v];22 if (v>=A[j-1]) d[i][j][v] += d[i-1][j-1][v-A[j-1...
分类:
其他好文 时间:
2014-12-24 13:22:01
阅读次数:
206
Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from the orig...
分类:
其他好文 时间:
2014-12-24 11:36:21
阅读次数:
173
题目:
You are climbing a stair case. It takes n steps to reach to the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
思路解析:
无法一下子判断是 Fib...
分类:
编程语言 时间:
2014-12-23 15:39:32
阅读次数:
309
MongoDB除了基本查询功能之外,还有强大的聚合工具,其中包括:count()、distinct()、group()、mapreduce. 计数函数count count是最简单的聚合工具,用于返回文档的数量: >db.user.count() // 返回集合user的个数 传递查询文档时,则计算...
分类:
数据库 时间:
2014-12-22 21:06:31
阅读次数:
183
Given 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 no...
分类:
其他好文 时间:
2014-12-22 17:55:10
阅读次数:
220
为了去重复,写了一个通用的比较容器类,可以用在需要比较的地方,且支持Lamda表达式
dataTable.AsEnumerable().Distinct(new DataComparer((x, y) => return (x[1] == y[1] && x[2] ==y[2]))).CopyT...
分类:
其他好文 时间:
2014-12-22 17:38:43
阅读次数:
122