Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Question on Union All
Message
 
 
À
22/03/2010 02:23:05
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01455995
Message ID:
01456024
Vues:
49
In UNION queries only ORDER BY is applied to the final recordset. All other clauses belong to particular SELECT. Your query asks for 10 records from the first select and all records from the second select.

>I have this SQL and I cannot understand why it returns 11 rows when there is a TOP 10 syntax:
>
>
>DECLARE @Enabled Bit
>DECLARE @Public Bit
>DECLARE @Public2 Bit
>
>SET @Enabled=1
>SET @Public=1
>SET @Public2=1
>
>SELECT TOP 10 Class.Title,Class.Notes,Class.AddDate,Class.ModDate,Class.Numero
> FROM Class
> UNION ALL
> SELECT ClassMethod.Title,ClassMethod.Notes,ClassMethod.AddDate,ClassMethod.ModDate,ClassMethod.Numero 
>  FROM ClassMethod
>  ORDER BY AddDate DESC
>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform