MYSQL行号使用实例
来源:互联网 发布:中信证券 for mac 编辑:程序博客网 时间:2024/05/22 10:26
select fk_device_id, DEVICE_NO, CUR_VALUE, GIS_LONG, GIS_LAT, C_TIME
from (select fk_device_id,
C_TIME,
GIS_LONG,
GIS_LAT,
if((@device_no = DEVICE_NO or @device_no is null) and
((CUR_VALUE = 0 and
(@cur_value <> 0 or @cur_value is null)) or
(CUR_VALUE <> 0 and @cur_value = 0)),
@rank := 1,
@rank := 0) as rownum,
@device_no := DEVICE_NO as DEVICE_NO,
@cur_value := CUR_VALUE as CUR_VALUE
from (select s.fk_device_id,
s.DEVICE_NO,
s.C_TIME,
s.CUR_VALUE,
d.GIS_LONG,
d.GIS_LAT
from t_device_speed s
inner join t_device_gps d
on s.C_TIME = d.C_TIME
where s.c_time >=
(select date_sub(curdate(), interval 3 day))
and s.DEVICE_NO = ? limit 0, 1000
union
select s.fk_device_id,
s.DEVICE_NO,
s.C_TIME,
s.CUR_VALUE,
d.GIS_LONG,
d.GIS_LAT
from t_device_speed_history s
inner join t_device_gps_history d
on s.C_TIME = d.C_TIME
where s.c_time >=
(select date_sub(curdate(), interval 3 day))
and s.DEVICE_NO = ? limit 0, 1000) temp,
(select @rank := 0, @device_no := null, @cur_value := null) ranktemp
order by c_time) tmepresult
where rownum = 1
order by c_time
- MYSQL行号使用实例
- 使用mysql查询显示行号
- 使用mysql查询显示行号
- 使用mysql查询显示行号
- mysql 行号
- mysql 获取行号 递增行号
- mysql group_concat 使用实例
- mysql csv 使用实例
- mysql使用JTA实例
- mysql dump使用实例
- [转]MySQL 行号
- Mysql表的行号
- 关于mysql的“行号”
- mysql 获取行号
- mysql行号问题
- mysql加入行号
- mysql 查询 行号
- mysql 获取行号
- 【数学建模】CUMCM历年题分类
- Leetcode c语言-Implement strStr()
- 多线程
- 集合Bootstrap自定义confirm
- 循环语句及双重循环
- MYSQL行号使用实例
- Android Studio NDK 开发与调试(生成 .so 文件)
- java中的移位运算符:<<,>>,>>>
- Win10编译linphone-windows项目文件
- ViewPager的Fragment的配置
- 表格
- c语言--二级指针在函数间的传递和使用
- Spinner
- ContentResolver query 特殊条件查询: in,like