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.
| Author |
Topic |
|
stikiflem1
Starting Member
6 Posts |
Posted - 2005-02-09 : 21:31:55
|
| does anybody has an article here about the effects on using MAX in queries? is it that efficient? is there an alternatives aside from using MAX to get the maximum? |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-02-09 : 22:23:23
|
| You can also try:SELECT TOP 1 myColumn FROM myTable ORDER BY myColumn DESC...instead of:SELECT Max(myColumn) FROM myTableBut it's unlikely to make much difference. At best it will be just as fast as MAX() would be. However, from a logical standpoint MAX() makes more sense, and uses standard SQL functions and syntax. TOP is not supported by all SQL products. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-02-09 : 22:34:56
|
| Be cautious about max and min in the same statement.select @max = max(fld), @min = min(fld) from tblcan be a lot slower thanselect @max = max(fld) from tblselect @min = min(fld) from tbl==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|