Optimal query
I have 2 tables1) CLIENTS (ID int IDENTITY, NAME varchar(250)
2) CLIENT_LOG( CLIENT_ID INT, DATE datetime )
Every time the client is selected in the system a row is put into the client_log.
Now i need to create a view showing the last 30 clients selected.
I currently use: select top 30 c.id, c.name from clients c join client_log l on l.client_id = c.id order by l.date desc
Only problem this is giving duplications if a client has been slected more than once in the last 30.
There are millions of records in each table so I need something pretty fast.
Thanks
Jonas