Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
First and last based on same SQL
Message
De
10/10/2014 11:10:51
 
 
À
10/10/2014 11:07:42
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2012
Application:
Web
Divers
Thread ID:
01609079
Message ID:
01609138
Vues:
43
>I think the most simplified way to do this and it seems to work ok is like this:
>
>
>SELECT 
>   (SELECT TOP 1 Invoice.ApprovedPersonName FROM Invoice WHERE Invoice.NoClient=Client.Numero ORDER BY Invoice.AddDate) AS FirstPerson,
>   (SELECT TOP 1 Invoice.ApprovedPersonName FROM Invoice WHERE Invoice.NoClient=Client.Numero ORDER BY Invoice.AddDate DESC) AS LastPerson
>
Just to fully understand your requirements: do you want to retrieve FirstPerson and LastPerson for each one of Client.Numero or just for an specific one that is set somewhere else in your application?
----------------------------------
António Tavares Lopes
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform