When in the Files tab, you can either upload a SQL file (see To upload files using the web interface for more information) or click the 'Add' dropdown menu and select 'New File'. You are then taken to the 'New file' page. Enter a filename, select the destination for the new file and ensure you have selected Structured Query Language file (.sql) from the 'Which type of file?' dropdown. Finally select 'Create new .sql File' and you will proceed to the editor page, from where you can edit the SQL file.
Once your file has been created, you can run either individual statements or the entire file. When on the SQL editor page, highlight the SQL file then click the 'Run File' button. Note that you do not need to save the SQL file before running it.
You can also save fetched output as a new Custom View, save as a new file, and open data in the new tab using buttons displayed in the top-right of the results output section.