2009-07-09 16 views
25

Quando faccio funzionare la domanda:SQL Server sottoquery sintassi

select count(*) from 
(select idCover from x90..dimCover group by idCover having count(*) > 1) 

ottengo l'errore:

Server: Msg 170, Level 15, State 1, Line 2 
Line 2: Incorrect syntax near ')' 

Come faccio a formulare correttamente questa ricerca?

Sono in SQL Server 2000

risposta

38

Aggiungere un alias dopo l'ultima staffa.

select count(*) from 
(select idCover from x90..dimCover group by idCover having count(*) > 1) a 
14
SELECT COUNT (*) FROM 
(SELECT IdCover FROM x90..dimCover group by idCover having count(*) > 1) AS a 

(notare l'alias alla fine)