SELECT OUD_OBJECT,OUD_OBJECT_ORG,OUD_UOM AS UOM,
(SELECT UOM_DESC FROM R5UOMS WHERE UOM_CODE=OUD_UOM) AS
DESCRIPTION,
OUD_TOTALUSAGE AS TOTALUSAGE,OUD_METER AS PHYSICALMETER,
OUD_LASTREADDATE AS LASTREADINGDATE,
OUD_PARENT AS PARENT,OUD_CHILD AS CHILD,
OUD_SINCEINSTALL AS USAGESINCEINSTALL,
OUD_SINCELASTWORK AS USAGESINCELASTWO,
MET_MAX AS METERROLLOVER,
IFNULL(MET_LAST, OUD_TOTALUSAGE) AS METERLASTVALUE,
OUD_UPDOWNMETER AS UPDOWNMETER
FROM  R5OBJUSAGEDEFS
LEFT OUTER JOIN R5METERS ON MET_CODE=OUD_METER
WHERE OUD_OBJECT=<parameter.object> AND OUD_OBJECT_ORG =<parameter.objectorg>
