update
This commit is contained in:
@ -179,7 +179,7 @@ async function tripGrouping() {
|
||||
|
||||
const q2 = `
|
||||
insert into trips
|
||||
(id,name,nopol1,vhc_id,mileage,start,finish,startMileage,finishMileage,startLoc,finishLoc,pool_code,dc_code,row_count)
|
||||
(id,name,nopol1,vhc_id,mileage,start,finish,startMileage,finishMileage,startLoc,finishLoc,pool_code,dc_code,row_count,fuel_consume)
|
||||
WITH
|
||||
gaps AS (
|
||||
SELECT
|
||||
@ -232,7 +232,8 @@ async function tripGrouping() {
|
||||
MAX(a.vhc_milleage) AS finishMileage,
|
||||
(SELECT fulladdress FROM t_gps_tracks_address WHERE master_id = MIN(a.id) LIMIT 1) AS startLoc,
|
||||
(SELECT fulladdress FROM t_gps_tracks_address WHERE master_id = MAX(a.id) LIMIT 1) AS finishLoc,
|
||||
COUNT(*) AS row_count
|
||||
COUNT(*) AS row_count,
|
||||
max(fuel_count) - min(fuel_count) AS fuel_consume
|
||||
FROM t_vehicles v
|
||||
LEFT JOIN numbered a ON a.vhc_id = v.id
|
||||
WHERE
|
||||
@ -255,7 +256,8 @@ async function tripGrouping() {
|
||||
finishMileage = values(finishMileage),
|
||||
startLoc = values(startLoc),
|
||||
finishLoc = values(finishLoc),
|
||||
row_count = values(row_count)
|
||||
row_count = values(row_count),
|
||||
fuel_consume = values(fuel_consume)
|
||||
`
|
||||
const d2 = [startOfMonth, endOfMonth]
|
||||
const r2 = await db.query(q2, d2)
|
||||
|
||||
Reference in New Issue
Block a user