Geoserver has this really great feature whereby admins are able to create views that are held with the configuration of the Geoserver but separate from the database. This allows admins the ability to create views WITHOUT the need to have database admin rights on the server. This is particularly useful where you have an onsite vendor database that you would not otherwise be allowed to write views in but nonetheless you require some way to store spatially enabled views .
Quick setup guide how to do this.
Select the Store that you are interested in
Next you should see text and just hit it.
Then there will be a place where you can put the SQL Statement in.