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 |
|
cableca
Starting Member
6 Posts |
Posted - 2008-03-04 : 14:17:01
|
| I have 2 tables. table A has all the information I need. table b has all the months I want to show. How can I join the tables on the month field and have all the months from table b show even if the months are not in table A? I have my query below.SELECT b.f_month,disc_check_in_month,region,product_group,count(product_group) as cntFROM collections.v_nonpays aleft join collections.filler_months bon (a.disc_check_in_month=b.f_month)where disc_check_in_month >='2007-01-01'Thanks!! |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-03-04 : 14:20:03
|
SELECT b.f_month,a.disc_check_in_month,a.region,a.product_group,count(a.product_group) as cntFROM collections.filler_months as bleft join collections.v_nonpays as a on a.disc_check_in_month = b.f_monthand a.disc_check_in_month >= '2007-01-01'group by b.f_month,a.disc_check_in_month,a.region,a.product_group E 12°55'05.25"N 56°04'39.16" |
 |
|
|
cableca
Starting Member
6 Posts |
Posted - 2008-03-04 : 14:49:12
|
| Thanks for your quick response. I tried the query you gave me but now the counts in the 'cnt' column are much higher. any thoughts as to why the counts are higher? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
|
|
|
|