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 |
|
purplecruz
Starting Member
7 Posts |
Posted - 2008-12-31 : 12:53:06
|
| I have been trying to find some duplicate entries in a table but the simple count(*) > 1 method is not enough in this case.I have a table with plots (plot_ID) that are located in stands (stand_ID). I would like to find if one plot is in more than one stand. The problem is that any plot may have multiple trees in it, so there could be more than one of the same plot_IDs per stand but it should only be associated with one stand_ID.Any help would be greatly appreciated.I can also provide an example to clarify if needed.Thanks!Stacy |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
purplecruz
Starting Member
7 Posts |
Posted - 2008-12-31 : 13:04:14
|
| Here is an example:stand_ID Plot_ID12345 112345 112345 112345 212345 245678 345678 367890 267890 267890 4In this case there are two plots (1 and 2) in the first stand (12345). Plot 1 has 3 trees and plot 2 has two trees.The next stand(45678) only has one plot(plot 3) with two trees.In the last plot (67890) there are two plots (2 and 4), but plot 2 has already been used in stand 12345. That is the error I would like to find. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
purplecruz
Starting Member
7 Posts |
Posted - 2008-12-31 : 13:52:19
|
| Thank You-that worked!Just curious-why is the t needed before the Group By? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|