Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help with TOP and UNION
Message
 
 
À
27/12/2004 11:28:44
John Deupree
Long Term Care Authority
Tulsa, Oklahoma, États-Unis
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00972363
Message ID:
00972368
Vues:
13
This message has been marked as the solution to the initial question of the thread.
Try (not tested)
SELECT plan, begindate 
	FROM mytable 
	WHERE begindate IN ( 
		SELECT TOP 2 begindate 
		FROM mytable 
		ORDER BY begindate DESC) 
UNION ALL
	SELECT MAX(plan) + 1, CAST(Null AS D)
	FROM mytable 
ORDER BY begindate DESC
>Oops, sorry. I know the problem of not being able to use the order by in the first select. Any ideas on how to return the correct results?
>
>John
>
>>You've to add 'order by begin_date desc' to the first select in whcih case it cannot be UNION.
>>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform