How to copy a file in a remote onto your local machine:
scp REMOTE:FILENAME ./
REMOTE: where the file is FILENAME: the file you want to copy ./ where the file will be copied to (do not have to name it as it will use the name of the file in the remote
You can run a SQL query and pipe into a file on a remote location, then use method above to copy locally.