Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How can I do this with one view?
Message
From
07/05/2001 09:08:06
 
 
To
07/05/2001 07:27:56
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00504115
Message ID:
00504153
Views:
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
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform