小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']]; ...
随机推荐
- android开发3:四大基本组件的介绍与生命周期
android开发3:四大基本组件的介绍与生命周期 Android四大基本组件分别是Activity,Service服务,Content Provider内容提供者,BroadcastReceiver ...
- C#中使用命名管道进行进程通信的实例
原文:C#中使用命名管道进行进程通信的实例 1 新建解决方案NamedPipeExample 在解决方案下面新建两个项目:Client和Server,两者的输出类型均为"Windows 应用 ...
- cf442C Artem and Array
C. Artem and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- c语言 (linux下)
生成二进制 : gcc -o hello hello.c 生成汇编:gcc -o hello.s -S hello.c 生成预编译文件:gcc -o hello.i -E hello.c int ma ...
- C++内存泄露检測原理
转自:http://hi.baidu.com/jasonlyy/item/9ca0cecf2c8f113a99b4981c 本文针对 linux 下的 C++ 程序的内存泄漏的检測方法及事实上现进行探 ...
- Android高级图片滚动控件,编写3D版的图片轮播器
转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/17482089 大家好,好久不见了,最近由于工作特别繁忙,已经有一个多月的时间没写博 ...
- 注册AxtiveX控件
Win8.1或者Win7下 首先在“管理员的身份”运行cmd 然后输入:regsvr32 D:\***\*.ocx
- Hacker(24)----防范密码被轻易破解
无论什么类型密码,用户在设置时都有非常小心,防止自己设置的密码被他人轻易破解.为保护重要的文件和资料,可采用加密工具进行加密,即可选择Win7系统自带的BitLocker,也可使用Internet中很 ...
- MySql查看表信息
SELECT TABLE_NAME, TABLE_COMMENT -- 指定信息列 FROM `information_schema`.`tables` A WHERE A.`TABLE_SCHEMA ...
- 《第一行代码》学习笔记10-活动Activity(8)
1.除了onRestart()方法,其他都是两两相对的.三种生存期: (1)完整生存期:onCreate()~onDestroy().一般情况下,一个活动会在onCreate()中完成各种初始化操作, ...