Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
First and last based on same SQL
Message
De
09/10/2014 15:30:56
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
First and last based on same SQL
Versions des environnements
SQL Server:
SQL Server 2012
Application:
Web
Divers
Thread ID:
01609079
Message ID:
01609079
Vues:
68
This is probably an easy one but I just thought I would talk a little bit about it so to obtain the best way to do it.

Presently, I have two select commands which goes like this:
SELECT TOP 1 Invoice.ApprovedPersonName FROM Invoice WHERE Invoice.NoClient=Client.Numero ORDER BY Invoice.AddDate
SELECT TOP 1 Invoice.ApprovedPersonName FROM Invoice WHERE Invoice.NoClient=Client.Numero ORDER BY Invoice.AddDate DESC
I would say this can be done with one select command with the use of MIN(), MAX(). However, I am not sure if this would always be adequate:
SELECT MIN(Invoice.ApprovedPersonName) AS FirstOne,MAX(Invoice.ApprovedPersonName) AS LastOne
 FROM Invoice WHERE Invoice.NoClient=Client.Numero ORDER BY Invoice.AddDate
Is this about the proper way to do it?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform