Thanks everyone for helping, the fix has been found.
The first query in the question works. It was a Database problem.
Thanks everyone for helping!!