Can I use Views query in my custom code or not?
Long story shory, if you run the same query that the views module runs, you will get the same result.

If you are getting a different result this means that you


Don't run the same query (where do you get the views query from)
Don't provide the same dynamic variables if any is used


You should also note that Views has it's own magic variables in views, that only works in views, like ****CURRENT_LANGUAGE**** which maps to the current language.

You should also note that views does a lot of work in the theme layer to output data. Getting the same data from SQL doesn't mean that the actual output will be the same.