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 |
|
dhinasql
Posting Yak Master
195 Posts |
Posted - 2008-04-15 : 03:00:54
|
| Hi i have a two table names are lk_votefor, and voting,In voting table i have the column like voteforid, articleidin lk_votewfor table have columnu like voteforid voteforExample feelds arevoting------id voteforid articleid1 1 72 1 73 1 84 1 75 2 46 2 7lk_votefor----------voteforid Votefor1 Event2 Blog3 Forumhere i want to know which article have more vote? it may b event,blog,or forum... But i want to know which article have most occurance in each type.Here voteforid 1 (Event)occures 4 type, for article 7 , it occures 3 times, so this is the max count... Expected output is article 7 has max vote in EventPlease help me for geting the expected output...Thanks in advance, its urgent pls |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2008-04-15 : 03:09:00
|
| What have you tried so far?HINT: Use GROUP BY |
 |
|
|
dhinasql
Posting Yak Master
195 Posts |
Posted - 2008-04-15 : 03:13:12
|
| I have used this query , using this i can get max number of occurance of voteforid.select voteforid,count(voteforid)from votinggroup by voteforidBut i want to know which article have most occurance in each type.Here voteforid 1 (Event)occures 4 type, for article 7 , it occures 3 times, so this is the max count... Expected output is article 7 has max vote in Event |
 |
|
|
dhinasql
Posting Yak Master
195 Posts |
Posted - 2008-04-15 : 03:23:24
|
| If u need more expl. plz ask me, its urgent help me |
 |
|
|
Vadivu
Starting Member
31 Posts |
Posted - 2008-04-15 : 03:27:32
|
| Check if this query works... pls anyone correct me if i am wrong...select top 1 count(voteforid) AS NoOfoccurance,voteforid,articleid from votinggroup by voteforid, articleidorder by count(voteforid) desc |
 |
|
|
dhinasql
Posting Yak Master
195 Posts |
Posted - 2008-04-15 : 05:57:08
|
| Hi FriendThanks for Your valuable help... Thank u very much |
 |
|
|
|
|
|
|
|