How can I write a raw sql query?

You might also have a look at…

…for raw queries