Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
First and last based on same SQL
Message
From
09/10/2014 23:24:19
 
 
To
09/10/2014 22:23:13
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2012
Application:
Web
Miscellaneous
Thread ID:
01609079
Message ID:
01609095
Views:
37
>>
Will be back online later and will type out example

When a person wants a single column value associated
with an aggregation (min, max ) ,
Then a cte or sub query or sub select is needed

Back online in a bit


Michel, I think it's a bit unclear what the query is trying to accomplish.
>
>Yes, this might not have been the best example to demonstrate it. Basically, there is a master table and it has one or several child records for each record. If we take the scenario that one master record has 5 child records, where each of them contains a textual field, the goal is to collect the first textual field value based on an order on AddDate, as well as the last value.
>
>So, basically, if the 5 records are like this:
>
>AddDate Name
>05/05/2014 Michel Fournier
>06/05/2014 Michel Fournier
>15/06/2014 James Bond
>01/07/2014 James Bond
>10/10/2014 King Kong
>
>I need to have Michel Fournier as the first one and King Kong as the last one.
>
>So, the goal is to see if I can extract those two values in one SQL or using two is pretty much what is needed.
Previous
Reply
Map
View

Click here to load this message in the networking platform