MySQL面试题1
来源:互联网 发布:文明5ige编辑器 Linux 编辑:程序博客网 时间:2024/06/03 22:50
events
272015-05-09 12:54:39
222015-05-09 14:48:30
3162015-05-09 13:19:57
3202015-05-09 15:01:09
4-422015-05-09 13:19:57
To a table that has event_type and value, which is the substraction of the last two records' value.
name value
2 -5
3 4
select event_type, value from (select event_type, res as value,if(@type = l2.event_type, @rank := @rank + 1, @rank := 1) as rank,@type := l2.event_type as typefrom(select l1.*, if(@t = l1.event_type, @res := l1.value - @prev, NULL) as res, @prev := l1.value as prev,@t := l1.event_type as typefrom events l1 join (select @t := NULL, @prev := NULL, @res := NULL) initorder by l1.event_type) l2join (select @type := NULL) initwhere res is not nullorder by event_type, time desc) l3where rank < 2;
0 0
- MySQL面试题1
- MYSQL面试题
- Mysql面试题精选
- mysql面试题集锦
- MySql面试题
- mysql一道面试题
- Mysql面试题精选
- mysql面试题
- mysql经典面试题
- Mysql面试题精选
- mysql 面试题
- MySQL 面试题
- MYSQL数据库面试题
- MySQL面试题(经验)
- mysql面试题
- Mysql面试题精选
- MySQL DBA 面试题
- Mysql面试题精选
- Every derived table must have its own alias
- java代码操作zip文件--写入zip文件
- retrofit的应用
- 52. N-Queens II(dfs)
- gdb调试多进程、线程
- MySQL面试题1
- linux工具命令--sort
- VS2010/MFC编程入门之二十六(常用控件:滚动条控件Scroll Bar)
- Anguarjs的四大特性
- HTTP与HTTPS详解
- RPC-Thrift简单应用
- 【日常收获7】修改ImageView显示的长宽比例
- Hibernate中update()和merge()的区别
- zookeeper 入门指南(译)