Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
1. Add a proper index.N 56°04'39.26"E 12°55'05.63"
lionofdezert
Aged Yak Warrior
885 Posts
Posted - 2011-05-09 : 07:21:05
proper indexes on columns, involved in JOIN,WHERE and GROUP BY clauses--------------------------http://connectsql.blogspot.com/
mmarovic
Aged Yak Warrior
518 Posts
Posted - 2011-05-11 : 18:01:10
1. Replace outer with inner join or move condition tb.tbRateDate <= @date from where clause to join .. on.2. Take care of indexes. If you provide more info about number of rows in tables and number of distinct values of each column we might be able to recommend an index.MirkoMy blog: http://mirko-marovic-eng.blogspot.com/
SwePeso
Patron Saint of Lost Yaks
30421 Posts
Posted - 2011-05-12 : 01:23:19
quote:Originally posted by mmarovic 1. Replace outer with inner join or move condition tb.tbRateDate <= @date from where clause to join .. on.
Not really. What is there are not matching records between the two tables. MAX will return NULL in original query.With INNER JOIN that is not longer a possibility.N 56°04'39.26"E 12°55'05.63"
mmarovic
Aged Yak Warrior
518 Posts
Posted - 2011-05-12 : 02:12:42
quote:Originally posted by Peso
quote:Originally posted by mmarovic 1. Replace outer with inner join or move condition tb.tbRateDate <= @date from where clause to join .. on.
Not really. What is there are not matching records between the two tables. MAX will return NULL in original query.With INNER JOIN that is not longer a possibility.N 56°04'39.26"E 12°55'05.63"
It will not return null as long as condition tb.tbRateDate <= @date is in where clause.MirkoMy blog: http://mirko-marovic-eng.blogspot.com/
SwePeso
Patron Saint of Lost Yaks
30421 Posts
Posted - 2011-05-12 : 12:16:42
Ah. Good point. I read that " tb.tbRateDate <= @date " was part of the JOIN condition, not the WHERE clause.N 56°04'39.26"E 12°55'05.63"