fix query to avoid NULL response

Signed-off-by: Santiago Pestarini <santiagonob@gmail.com>