Efficient SQL query to sum unsettled trades by date -


I have a table of trades, which includes fields for the amount, business date and settlement date

< P> I want

Select the amount (s) from the trades with trades where the trade date & lt; = @ Date and Settlement Date & gt; @ Date

There is a way to do this (simplified):

  Select Date, (business date and date = date and deal with allads Date & date;)  

Is there a more efficient way to do this? I think the sub-question makes it slow?

Thanks for any help

With a plain join: < / P>

  Select AllDates.date, SUM (trades.mount) Trades on trades in all trades. Trademarks & lt; = Alldetset and trades Settlement & amp; AllDates.date by AllDates.date Group  

Comments