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 |
|
codrgiii
Starting Member
29 Posts |
Posted - 2009-05-29 : 14:30:05
|
| How am i able to select from a whole column if the result is more than the 1 of the same result?To break it down a lil, say i wanted to select from table WORK and from column usage, how would i be able to select the results of the usage column if 2 of more results were the same? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-29 : 14:37:17
|
do you mean this?SELECT DISTINCT usage FROM WORK |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-05-29 : 15:11:57
|
| Or do you mean you want to find only the duplicates?select usage, count(*) [occurrence_count]from workgroup by usagehaving count(*) > 1Be One with the OptimizerTG |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-30 : 02:30:45
|
| would apprecaite if you could give us some sample data and explain what you want rather than keeping us guessing |
 |
|
|
chriztoph
Posting Yak Master
184 Posts |
Posted - 2009-06-01 : 01:30:01
|
| hi!what if i want to show like this+-------------+-------|Country | +-------------+-------|Phil |+-------------+-------|Phil |+-------------+-------|USA |+-------------+-------|USA |+-------------+------|Phil |+-------------------_ |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-06-01 : 01:36:40
|
have you tried the query TG posted ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
chriztoph
Posting Yak Master
184 Posts |
Posted - 2009-06-01 : 01:39:52
|
yup but it shows like this+-------------+-------|Country |+------ ---+-------|Phil |3+----------+-------|USA |2+----------+------- |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-06-01 : 01:52:16
|
just inner join back to your original tableselect t.Countryfrom yourtable t inner join ( select Country from yourtble group by Country having count(*) > 1 ) m on t.Country = m.Country KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|