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 |
|
vwilsonjr
Starting Member
45 Posts |
Posted - 2002-12-17 : 10:37:24
|
| I have to tables that I'm joining together. I have 2 fields that I'm using as keys. The first table (fips_codes) has 1872 records. The second table (aggregate) has 14306 records. I'm joining using the following codefrom aggregate join fips_codeon (fips_code.st_fips = aggregate.state_code_fips)and (fips_code.co_fips = aggregate.county_code_fips)My problem is when I run the query I get 17033 records. Can anyone point me in the right direction? |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-12-17 : 11:08:45
|
| There are probably some rows in the Aggregate table that have more than one row for each state_code_fips and county_code_fips combination. Run this query:SELECT state_code_fips, county_code_fips, count(*) AS rowsFROM aggregateGROUP BY state_code_fips, county_code_fipsHAVING Count(*)>1And see if you get any results. That will identify any combination having more than one row. If there are "dupes", and they are legitimate, then you'll get multiple matches using the join you have now. |
 |
|
|
|
|
|