Create a table with the subquery
Create unique index --use exceptions into clause.

You get it.