Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
First and last based on same SQL
Message
From
10/10/2014 02:49:30
 
 
To
10/10/2014 02:33:45
Walter Meester
HoogkarspelNetherlands
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2012
Application:
Web
Miscellaneous
Thread ID:
01609079
Message ID:
01609116
Views:
45
>Michel,
>
>From what I sense, you want to have the fist and latest person that approved any invoice for every client? Correct?
>
>I think it can be done very simple:
>
>
>SELECT *,
>   (SELECT TOP 1 ApprovedPersonName FROM Invoices WHERE NoClient = Client.Numero ORDER BY AddDate ) as firstperson,
>   (SELECT TOP 1 ApprovedPersonName FROM Invoices WHERE NoClient = Client.Numero ORDER BY AddDate DESC) as Lastperson,
>   FROM Client
>
>

I like that one.
Previous
Reply
Map
View

Click here to load this message in the networking platform