Always enclose the select statement of a subquery in parentheses. The select syntax for a subquery is somewhat restricted:
(select [all | distinct] subquery_select_list
[from [[database.]owner.]{table_name |view_name}
[({index indexation | prefetch size | [lru | mru]})]}
[holdlock | noholdlock] [shared]
[,[[database.]owner.]{table_name | view_name}
[{index indexation | prefetch size | [lru | mru]})]}
[holdlock | noholdlock] [shared]]...]
[where search_conditions]
[group by aggregate_free_expression [,
aggregate_free_expression]...]
[having search_conditions])