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 |
|
voliveira
Starting Member
5 Posts |
Posted - 2006-12-05 : 08:27:52
|
| Hi everyone,sorry for the stupid question, but i've been looking for this answer for a while.I have a table like thisID value1 52 33 194 55 56 27 5I'd like to select the value the most occur in this table.In this case would be the number 5.How can i do that using the SELECT command?Sorry again for the stupid question.Thanks and regards,Vinicius Oliveira |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-05 : 08:29:00
|
| select value, count(*) from yourtablenamehereorder by 2 descselect top 1 value, count(*) from yourtablenamehereorder by 2 descPeter LarssonHelsingborg, Sweden |
 |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2006-12-05 : 08:36:45
|
| Add to Peso's ... group by valueJayto here knows when |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-12-05 : 08:39:52
|
Thanks! Peter LarssonHelsingborg, Sweden |
 |
|
|
voliveira
Starting Member
5 Posts |
Posted - 2006-12-05 : 08:56:32
|
Thank you very much.Worked fine.regards,Vinicius Oliveira |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|