How does MySQL calculate the difference of a certain column in two adjacent rows

MySQL calculates the difference between two adjacent rows of a certain column: First, use [r1.rownum = r2.rownum – 1] to determine whether the two records are consecutive rows; then use the TIMEDIFF function to calculate the time difference That’s it. 【Related learning recommendation: mysql tutorial(video)】 MySQL calculates the difference between two adjacent rows and a column: First, the blogger has a table on the server side to record the GPS reported by the driver Point information, the table structure is as follows: — driver GPS collection table CREATE TABLE captainad_driver_gps_position ( id BIGINT NOT NULL auto_increment COMMENT ‘primary key’, business_id BIGINT DEFAULT NULL COMMENT ‘Business ID’, device_mac VARCHAR (64) DEFAULT NULL COMMENT ‘Device MAC address’, device_imei VARCHAR (64) DEFAULT NULL COMMENT ‘Device IMEI’, lat_lng VARCHAR (64) DEFAULT NULL COMMENT ‘latitude and longitude’, capture_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT ‘capture time’, create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT ‘Create Time’, update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT ‘Modify time’, PRIMARY KEY (id), KEY `idx_business_id` (`business_id`) USING BTREE ) ENGINE = INNODB DEFAULT CHARSET = utf8 COMMENT = & # 39; driver GPS collection & # 39;; The data recorded in the table is roughly as follows: Click to get GPS now After the…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索