Hi.. I'm running the select query below without any problems. Issue is it give me all the locations (POSHIST.LATITUDE) table. Positions in this table are reported every 15 minutes, so I need to just get the most recent position. In less complex queries (without this combination of joins) I'm able to use this code to get the most recent position:
>>>>inner join lynx.poshist poshist on poshist.device = mobile_device.device_id where poshist.PosDate = (select max(PosDate) FROM lynx.poshist WHERE device = mobile_device.device_Id )<<<<<
Can someone tell me how I can get this into the code below to show the latest position? Thanks for help!!!
SELECT TLORDER.BILL_NUMBER, SVCLEVEL.CODE, TLORDER.PICK_UP_BY, ITRIPTLO.CURRENTLY_ASSIGNED, ITRIPTLO.TRIP_NUMBER, PUNIT.UNIT_ID, MOBILE_DEVICE.DEVICE_ID, WEB_CLIENT_GROUPINGS.GROUP_NAME, WEB_CLIENT_GROUPINGS.CLIENT_ID, WEB_USER_GROUPS.GROUP_NAME, WEB_USERS.EMAIL, POSHIST.LATITUDE
FROM (((LYNX.TLORDER TLORDER INNER JOIN LYNX.ITRIPTLO ITRIPTLO ON TLORDER.BILL_NUMBER=ITRIPTLO.BILL_NUMBER) INNER JOIN ((LYNX.WEB_USER_GROUPS WEB_USER_GROUPS INNER JOIN LYNX.WEB_CLIENT_GROUPINGS WEB_CLIENT_GROUPINGS ON WEB_USER_GROUPS.GROUP_NAME=WEB_CLIENT_GROUPINGS.GROUP_NAME) INNER JOIN LYNX.WEB_USERS WEB_USERS ON WEB_USER_GROUPS.USER_ID=WEB_USERS.USER_ID) ON TLORDER.BILL_TO_CODE=WEB_CLIENT_GROUPINGS.CLIENT_ID) INNER JOIN LYNX.SVCLEVEL SVCLEVEL ON TLORDER.SERVICE_LEVEL=SVCLEVEL.CODE) INNER JOIN LYNX.PUNIT PUNIT ON MOBILE_DEVICE.ASSIGNED_TO=PUNIT.UNIT_ID) ON ITRIPTLO.TRIP_NUMBER=PUNIT.CURRENT_TRIP INNER JOIN ((LYNX.POSHIST POSHIST INNER JOIN LYNX.MOBILE_DEVICE MOBILE_DEVICE ON POSHIST.DEVICE=MOBILE_DEVICE.DEVICE_ID)
WHERE TLORDER.PICK_UP_BY>={ts '2010-05-21 00:00:00'}
>>>>inner join lynx.poshist poshist on poshist.device = mobile_device.device_id where poshist.PosDate = (select max(PosDate) FROM lynx.poshist WHERE device = mobile_device.device_Id )<<<<<
Can someone tell me how I can get this into the code below to show the latest position? Thanks for help!!!
SELECT TLORDER.BILL_NUMBER, SVCLEVEL.CODE, TLORDER.PICK_UP_BY, ITRIPTLO.CURRENTLY_ASSIGNED, ITRIPTLO.TRIP_NUMBER, PUNIT.UNIT_ID, MOBILE_DEVICE.DEVICE_ID, WEB_CLIENT_GROUPINGS.GROUP_NAME, WEB_CLIENT_GROUPINGS.CLIENT_ID, WEB_USER_GROUPS.GROUP_NAME, WEB_USERS.EMAIL, POSHIST.LATITUDE
FROM (((LYNX.TLORDER TLORDER INNER JOIN LYNX.ITRIPTLO ITRIPTLO ON TLORDER.BILL_NUMBER=ITRIPTLO.BILL_NUMBER) INNER JOIN ((LYNX.WEB_USER_GROUPS WEB_USER_GROUPS INNER JOIN LYNX.WEB_CLIENT_GROUPINGS WEB_CLIENT_GROUPINGS ON WEB_USER_GROUPS.GROUP_NAME=WEB_CLIENT_GROUPINGS.GROUP_NAME) INNER JOIN LYNX.WEB_USERS WEB_USERS ON WEB_USER_GROUPS.USER_ID=WEB_USERS.USER_ID) ON TLORDER.BILL_TO_CODE=WEB_CLIENT_GROUPINGS.CLIENT_ID) INNER JOIN LYNX.SVCLEVEL SVCLEVEL ON TLORDER.SERVICE_LEVEL=SVCLEVEL.CODE) INNER JOIN LYNX.PUNIT PUNIT ON MOBILE_DEVICE.ASSIGNED_TO=PUNIT.UNIT_ID) ON ITRIPTLO.TRIP_NUMBER=PUNIT.CURRENT_TRIP INNER JOIN ((LYNX.POSHIST POSHIST INNER JOIN LYNX.MOBILE_DEVICE MOBILE_DEVICE ON POSHIST.DEVICE=MOBILE_DEVICE.DEVICE_ID)
WHERE TLORDER.PICK_UP_BY>={ts '2010-05-21 00:00:00'}