今天在写代码的时候遇到了点问题,特意记下,以免忘记!四舍五入方法: // num为传入的值,n为保留的小数位 function fomatFloat(num,n){ var f = parseFloat(num); if(isNaN(f)){ return false; } f = Math.round(num*Math.pow(10, n))/Math.pow(10, n); // n 幂 var s = f.toString(); var rs = s.indexOf('.'); //判定如…
使用cast 函数可以把字符类型字段(数学形式)转换为数字 比如 AND m.nfrc_meeting_no=? ORDER BY cast(m.BOOTH AS INT) ASC "; 结果:(m.BOOTH)是展位号 假如直接使用 AND m.nfrc_meeting_no=? ORDER BY m.BOOTH ASC "; 会出现 10 5 51 60 这种顺序,因为是按字符串排序…
基础 1.查看所有数据库: show dbs 2.选择数据库: use test 3.查看数据库中有哪些集合: show collections 如下图: 查询 1.查看集合中有哪些数据,其中abc为集合名称: 2.为查询添加过滤条件a=2: 3.指定查询结果集中包含的字段,如下查询仅包含字段a/b,注意,此处除了_id字段外,其他字段要么全是1,要么全是0: 4.综合示例: db.kpiRecord.find( { cellCode:"48BF74_12020000051TST0001&quo…
题目 public class Test { public static void main(final String[] args) { final int a = 10; final int b = 20; System.out.println(a + '+' + b + '=' + (a + b)); } } 乍一看,可能有的同学会觉得很简单,直接给出如下答案: 10+20=30 其实这是道陷进题,很容易就看混了,正确的答案是: 164 分析 为什么答案会是164? 这是因为这里并不是字符…
在做交叉报表列头的排序时,遇到这三个问题,下面具体来说一下. 设计的数据库的表结构如图1所示: 图1 要处出来student_name_,s.grade_,s.subject_name_,这三个属性,当时我是这样写的sql语句: select s.student_name_, s.grade_, s.subject_name_, case s.subject_name_ when '语文' then 'A语文' when '数学' then 'B数学' when '英语' then …
mongo Shell Command History You can retrieve previous commands issued in the mongo shell with the up and down arrow keys. Command history is stored in ~/.dbshell file. See .dbshell for more information. Command Line Options The mongo shell can be sta…
MongoDB BSON provides support for additional data types than JSON. Drivers provide native support for these data types in host languages and the mongo shell also provides several helper classes to support the use of these data types in the mongo Java…
You can write scripts for the mongo shell in JavaScript that manipulate data in MongoDB or perform administrative operation. For more information about the mongo shell, see the Running .js files via a mongo shell Instance on the Server section for mo…