SQL for reporting on SharedSolar gateway DB