Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
First and last based on same SQL
Message
From
09/10/2014 22:08:21
 
 
To
09/10/2014 15:30:56
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2012
Application:
Web
Miscellaneous
Thread ID:
01609079
Message ID:
01609089
Views:
45
>
>
>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?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform