Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How can I do this with one view?
Message
De
07/05/2001 09:27:30
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00504115
Message ID:
00504160
Vues:
18
>Hi!
>
>You can combine them in a single query:
>
>
>SELECT SmtDetail.*
>  FROM dbo.SmtDetail INNER JOIN
>    (SELECT Member_Id, MAX(TS) AS Ts
>       FROM dbo.SmtDetail
>       GROUP BY Member_Id) MaxDetailTs ON
>         dbo.SmtDetail.Member_Id = dbo.MaxDetailTs.Member_Id AND
>         dbo.SmtDetail.TS = dbo.MaxDetailTs.Ts
>
>
>
>
>>I would like to accomplish the following without having to construct the MaxDetailTS view:
>>
>>View MaxDetailTS:
>>SELECT Member_Id, MAX(TS) AS Ts
>>FROM dbo.SmtDetail
>>GROUP BY Member_Id
>>
>>View DetailView:
>>SELECT SmtDetail.*
>>FROM dbo.SmtDetail INNER JOIN
>> dbo.MaxDetailTs ON
>> dbo.SmtDetail.Member_Id = dbo.MaxDetailTs.Member_Id AND
>> dbo.SmtDetail.TS = dbo.MaxDetailTs.Ts
>>
>>Is there a more efficient and/or neater way to accomplish this?
>>
>>TIA

I have tried it, and except for a small modification, it seems to work.
MaxDetailsTs is not part of the DB, so obviously the dbo. does not apply.

Thanks!
Peter Pirker


Whosoever shall not fall by the sword or by famine, shall fall by pestilence, so why bother shaving?

(Woody Allen)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform