This question already has an answer here:
I have a layer that is defined by a complex SQL query. It works fine but I would like to move that complexity out of QGIS and into the data base so I can access it from elsewhere (GeoServer).
I have tried creating a postgres view which represents the layer by using the database manager in QGIS (save as view) and by creating the view from the database itself but when I try and load the layer it is marked with a '!' and I can not select it.
Yes this is a duplicate question (sorry I don't know how to insert a reference to it) but the answers to that question don't work with current (2.18) versions of QGIS. In particular they do not include the step to click on the schema button which is what I was missing. I suspect that needing to do this is a bug but I will check this in QGIS 3 before reporting it as such.
The process of adding views is rather unintuitive and 'Get Spatial's explanation is clearer than any of the answers to the original question. If we dump my question (feel free :) then please ensure that this answer gets added to the original one.
I note that several people besides me have up voted that answer.