sql server 2008 - SQL - Nested Select in From claus with Count -


when use following code (it oracle guy , says there no reason not work...) notified there incorrect syntax located @ last ')'. idea how can change "sql appropriate"? thoughts not liking last select statement.

select      *       cpininvest       [case id||] not in          (         select [case id||]                       (             select [case id||], count(*)              cpincomm140              [role cd||]='pri||'              group [case id||]                having count(*)=1             )         ) 

it can shortened.

select * cpininvest  [case id||] not in (         select [case id||]         cpincomm140          [role cd||]='pri||'          group [case id||]          having count(*)=1     ); 

but seriously, pipes in fieldnames? yuk!

the reason why original query fail is:
1) count(*) needs alias. example [total]
2) tsql has odd requirement subqueries require alias


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -