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 |
flchico
Starting Member
46 Posts |
Posted - 2008-01-25 : 15:14:50
|
Is it generally a bad idea to have a query as a column in terms of speed? Is it better to try to do it as a join if possible?Basically I have a LEFT JOIN that should match to only a record but now the rules changed and sometimes it will match to 2 but I only need to pick one of those. If I create a query as a column I can do SELECT TOP 1 and I'm done but it's taking much longer to process. Any comments are appreciated, thanks! |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-26 : 11:19:06
|
I think you can also use a LEFT JOIN with subquery returning Top 1 value.something like:-SELECT fieldsFROM Table1 t1LEFT JOIN(SELECT TOP 1 field2 FROM table2 ORDER BY Field ASC/DESC) t2ON t2.field2=t1.field1 |
 |
|
|
|
|