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 |
|
papaboom
Starting Member
1 Post |
Posted - 2011-08-11 : 16:42:37
|
| Not sure what I'm doing wrong here - if someone could set me straight I would be grateful.SELECT r.Idx, r.valuerange, ISNULL(COUNT(s.[Status]),0) as valuecount \FROMDistillationBy25K as r LEFT OUTER JOIN Status as s ON s.listingprice < r.RangeMax AND s.listingprice >= r.rangeminINNER JOIN mls_data as m ON m.listingnumber = s.listingnumber AND m.mlssource = s.mlssourceWHERE (m.county like isnull(@County, m.county) + '%') and (m.mlssource like isnull(@Region, m.mlssource) + '%') and (m.schooldistrict like isnull(@Schooldistrict, m.schooldistrict) + '%') and (m.zip like isnull(@Zip, m.zip) + '%') and dateaddedmonth = month(@DateTo) and dateaddedyear = year(@DateTo) and s.status <> 'Sold'GROUP BY r.Idx, r.valuerange |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2011-08-11 : 16:56:04
|
| You have, effectivly, created an INNER JOIN by adding "s.status <> 'Sold'" to your WHERE clause. Perhaps you want to move that perdicate to the join condition instead? If that doesn't work we'll probably need more information. Here is a link that can help you prove that information in a consumable format for us:http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|