Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
First and last based on same SQL
Message
De
09/10/2014 22:08:21
 
 
À
09/10/2014 15:30:56
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:
01609089
Vues:
44
>
>
>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, I think it's a bit unclear what the query is trying to accomplish.

Can you briefly describe what you're trying to retrieve?

The way I read this....for each client in your client table, you want to read across all invoices and list the approver for the earliest invoice for that client....and also the most recent approver for the invoice.

In that case, I think you want to add client to the list in the SELECT, and also add a GROUP BY.

But then again, I'm not positive that that's what you're trying to do. As you've written the query, it will retrieve alphabetically the lowest alphabetic value for an approver (like Anderson) and then the highest alpha value (like Zimmerman). But I'm guessing that's not what you're looking for.

So can you clarify what you're trying to do?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform