一起艳恶学习开发遇到的坑(一)

来源:互联网 发布:淘宝达人直播申请 编辑:程序博客网 时间:2024/04/26 16:12

1、sql列转行

select a,b,c,d from test
select abcd from(select a from test union allselect b from test union allselect c from test union allselect d from test)

2、从table中第二个tr开始移除

$("#table tr:gt(0)").remove();

3、sql语句开发(oracle)

3.1 未来两天生日SELECT    *FROM    TESTWHERE    TO_DATE (birthday, 'MM-dd') >= TRUNC (SYSDATE)AND TO_DATE (birthday, 'MM-dd') <= TRUNC (SYSDATE) + 23.2 按每月查询(当前月)select * from test where to_char(sysdate,'yyyy-mm')=to_char(CREATE_TIME,'yyyy-mm');3.3 查询前十条select * from test where rownum <= 10;3.4 查询上一个月的select * from test where to_char(add_months(sysdate,-1),'yyyy-mm')=to_char(CREATE_TIME,'yyyy-mm');3.5 按第几月统计select to_char(CREATE_TIME,'mm') as monfrom   test  where to_char(CREATE_TIME,'mm') = '11'group by to_char(CREATE_TIME,'mm')3.6 任意3个月select to_char(CREATE_TIME,'mm') as monfrom   test where to_char(CREATE_TIME,'mm') = '11' or to_char(CREATE_TIME,'mm') = '06' or to_char(CREATE_TIME,'mm') = '05'group by to_char(CREATE_TIME,'mm')3.7 按季度查询select to_char(CREATE_TIME,'q'),sum(state)  from  test  group by to_char(CREATE_TIME,'q') 

4、table中图片回显

//回显图片                    var len = list1.data.length+1;                    var $tr = $(".tableCommon tr");                    for(var i=0;i<len;i++){                        $($tr[i]).children("td").eq(2).html("<img src='${baseURL}/xxx/fileUrl="+$($tr[i]).children("td").eq(2).text()+"' width='100'/>");

5、平均数计算(java)

public class TestNum {    public static void main(String[] args) {        double[] ary = {1,3,5,8,9};        String a = getAvgNum(ary);        System.out.println(a);    }    private static String getAvgNum(double[] ary) {        double sum=0;        for (int i = 0; i < ary.length; i++) {            sum=sum+ary[i];        }        double x = sum*1.0/ary.length;        DecimalFormat df = new DecimalFormat("#.00");        return df.format(x);    }}

6、地图经纬度精算范围

public class TestGpsMap {    public static void main(String[] args) {        double lat1 = 112.3456;        double lng1 = 23.3456;        double lat2 = 112.3256;        double lng2 = 23.3496;        double distance = getDistance(lat1, lng1, lat2, lng2);        System.out.println(distance);        if(distance < 1000){            System.out.println("签到成功!");        }    }    private static double EARTH_RADIUS = 6378.137;      private static double rad(double d) {          return d * Math.PI / 180.0;      }      /**      * 通过经纬度获取距离(单位:米)      * @param lat1      * @param lng1      * @param lat2      * @param lng2      * @return      */      public static double getDistance(double lat1, double lng1, double lat2,              double lng2) {          double radLat1 = rad(lat1);          double radLat2 = rad(lat2);          double a = radLat1 - radLat2;          double b = rad(lng1) - rad(lng2);          double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2)                  + Math.cos(radLat1) * Math.cos(radLat2)                  * Math.pow(Math.sin(b / 2), 2)));          s = s * EARTH_RADIUS;          s = Math.round(s * 10000d) / 10000d;          s = s*1000;          return s;      }  }
原创粉丝点击