fixed licence lookup by fixing raw sql

Fixed licence lookup by fixing raw sql.