小SQL大作用
从DBA那问来的,备份现有数据库表:
create table B select * from A ;
alter table book_order drop primary key;
alter table book_order add primary key(bookid,platform,stat_date);
根据小时分组数据
select date_format(inserttime,'%Y-%m-%d %H'),count(userid), count(distinct userid) from pppay_order_alipay where status=8888 and moneyType=1 and inserttime > '2013-10-16' and inserttime < '2013-10-23' group by date_format(inserttime,'%Y-%m-%d %H'); select date_format(from_unixtime(dateline),'%Y-%m-%d %H'),count(userid),count(distinct userid) from pppay_order where status=4 and moneyType=1 and from_unixtime(dateline) > '2013-10-16' and from_unixtime(dateline) < '2013-10-23' group by date_format(from_unixtime(dateline),'%Y-%m-%d %H');
date_format 函数生成这样的字符串2013-10-12 00 ~ 2013-10-12 23 数据集也根据这个进行分组
concat 字符串链接函数, format控制小数位数
select area,count(distinct userid) as uv, concat(format(count(distinct userid)/119089*100,2),'%') as uv_rate,sum(pv) as pv, concat(format(sum(pv)/1454985*100,2),'%') as pv_rate from foreigners group by area order by uv desc;
创建视图
create view byb_booklist_view as select distinct bid,price,date_format(stat_date,'%Y-%m') as month from byb_read_list where book_type=2;
修改字段名
alter table pay_stat_foruc change price price int;
小SQL大作用的更多相关文章
- CSS中zoom:1的作用 ,小标签大作用
CSS中zoom:1的作用兼容IE6.IE7.IE8浏览器,经常会遇到一些问题,可以使用zoom:1来解决,有如下作用:触发IE浏览器的haslayout解决ie下的浮动,margin重叠等一些问题. ...
- java中的@Override标签,小细节大作用
转载:http://www.cnblogs.com/octobershiner/archive/2012/03/09/2388370.html 一般用途 ...
- SQL 实现地区的实现树形结构递归查询(无限级分类),level为节点层级,由小至大依次
//SQL 实现地区的实现树形结构递归查询(无限级分类),level为节点层级,由小至大依次 2018-09-25 StringBuilder areaSQL = new StringBuilder( ...
- c++小学期大作业攻略(一)环境配置
UPDATE at 2019/07/20 20:21 更新了Qt连接mysql的方法,但是是自己仿照连VS的方法摸索出来的,简单测试了一下能work但是不保证后期不会出问题.如果你在尝试过程中出现了任 ...
- [小细节,大BUG]记录一些小问题引起的大BUG(长期更新....)
[小细节,大BUG] 6.问题描述:当从Plist文件加载数据,放入到tableView中展示时,有时有数据,有时又没有数据.这是为什么呢?相信很多大牛都想到了:我们一般将加载的数据,转换成模型,放入 ...
- SQL大数据操作统计
SQL大数据操作统计 1:select count(*) from table的区别SELECT object_name(id) as TableName,indid,rows,rowcnt FROM ...
- android FakeWindow的小应用大用途
android FakeWindow的小应用大用途 在windowmanager里面有一个FakeWindow,细致一看也就是一个透明的应用覆盖到屏幕的最前端,这样有什么优点呢?首先我们还是从应用的需 ...
- safari 与 chrome 的小区别大BUG
safari 与 chrome 的小区别大BUG 时间:2016-11-01 17:33:19 作者:zhongxia 原文地址:https://github.com/zhongxia245/blog ...
- 搜索条件两个时间,通过php数组排序,保证select语句between时间 前小后大
//搜索条件两个时间,通过数组排序,保证select语句between时间 前小后大 $sort_array=[$_POST['clockDate1'],$_POST['clockDate2']]; ...
随机推荐
- jboss-AS目录结构了解(资料摘取)
Directory Description bin Contains startup, shutdown and other system-specific scripts. Basically al ...
- FJ省队集训DAY2 T1
思路:转换成n条三维空间的直线,求最大的集合使得两两有交点. 有两种情况:第一种是以某2条直线为平面,这时候只要统计这个平面上有几条斜率不同的直线就可以了 还有一种是全部交于同一点,这个也只要判断就可 ...
- Unity 3D中的菜单项
1.File菜单:主要是包含项目和场景的创建.保存以及输出等功能.2.Edit(编辑)菜单:只要包括对场景进行一系列的编辑以及环境设置操作等命令.3.Assets(资源)菜单:掌握资源在Unity中的 ...
- 关于bat文件语法
@echo offecho 当前盘符:%~d0echo 当前盘符和路径:%~dp0echo 当前批处理全路径:%~f0echo 当前盘符和路径的短文件名格式:%~sdp0echo 当前CMD默认目录: ...
- MySQL所有函数及操作符
参考:Function and Operator Reference Name Description ABS() Return the absolute value ACOS() Return th ...
- CONTEST36 小Z的模拟赛(2)
A.小Z的可恶路障 题目:http://www.luogu.org/problem/show?pid=U126 题解:暴力也可以过吧.我为了保险先求了一次最短路,然后枚举这条最短路上的所有边... 代 ...
- 转:Android 测试 Appium、Robotium、monkey等框架或者工具对比
原文地址:http://demo.netfoucs.com/u012565107/article/details/36419297# 1. Appium测试 (功能测试,用户接受度测试,黑盒测试) - ...
- poj2752 Seek the Name, Seek the Fame
Description The little cat is so famous, that many couples tramp over hill and dale to Byteland, and ...
- [深入JUnit] 为什么别测试private函数
[深入JUnit] 为什么别测试private函数 摘自http://www.tuicool.com/articles/iumaayJ 时间 2016-03-28 10:58:03 SegmentFa ...
- JAVA并发实现五(生产者和消费者模式Condition方式实现)
package com.subject01; import java.util.PriorityQueue; import java.util.concurrent.locks.Condition; ...