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 |
|
nomadsoul
Yak Posting Veteran
89 Posts |
Posted - 2006-10-30 : 19:59:36
|
| Hello, I've done numerous select statements using DISTINCT, but what if I want to do the opposite of DISTINCT meaning I wantduplicate values but don't want single values? I have not coded much in T-SQL mainly MySQL. I certaily like TSQL, and Im using the new Sql Server Express 2005, love it.It is better to be prepared and not have an opportunity than to not be prepared and have an opportunity |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2006-10-30 : 20:03:52
|
Something like this should do itSELECT Field1, Field2, Field3, COUNT(*)FROM MyTableGROUP BY Field1, Field2, Field3HAVING COUNT(*) > 1 Michael<Yoda>Use the Search page you must. Find the answer you will. Cursors, path to the Dark Side they are. Avoid them, you must. Use Order By NewID() to get a random record you will.</Yoda>Opinions expressed in this post are not necessarily those of TeleVox Software, inc. All information is provided "AS IS" with no warranties and confers no rights. |
 |
|
|
nomadsoul
Yak Posting Veteran
89 Posts |
Posted - 2006-10-30 : 20:10:25
|
| Thanks MPThat was awesome fast. That was my first post here and naturally I didn't see the search link. I am trying it nowIt is better to be prepared and not have an opportunity than to not be prepared and have an opportunity |
 |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2006-10-30 : 21:24:07
|
| No worries about the Search. These days, it's not very effective. You'll find with posts here, most are answered rather quickly, esp during working hours in the USA.Michael<Yoda>Use the Search page you must. Find the answer you will. Cursors, path to the Dark Side they are. Avoid them, you must. Use Order By NewID() to get a random record you will.</Yoda>Opinions expressed in this post are not necessarily those of TeleVox Software, inc. All information is provided "AS IS" with no warranties and confers no rights. |
 |
|
|
|
|
|
|
|