Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
First and last based on same SQL
Message
De
09/10/2014 23:24:19
 
 
À
09/10/2014 22:23:13
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:
01609095
Vues:
36
>>
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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform