I want maximum number of votes from these 3 columns(cong, bjp and aap) with associate column name
my table is :
| Cong | BJP | AAP | Winner | Win By |
| 18515 | 72283 | 23757 | BJP | 48526 |
| 24730 | 29373 | 36863 | AAP | 7490 |
expected result:
| maxvote | Party Name |
| 72283 | BJP |
| 36863 | AAP |
| Cong | BJP | AAP | Winner | Win By |
| 18515 | 72283 | 23757 | BJP | 48526 |
| 24730 | 29373 | 36863 | AAP | 7490 |
| maxvote | Party Name |
| 72283 | BJP |
| 36863 | AAP |
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Feb 7, 2014, 11:23 PM EST
VulpesRank #55 · 29.2K reputationPosted Feb 7, 2014, 2:12 PM EST
SELECT CASE WHEN Cong >= BJP AND Cong >= AAP THEN Cong
WHEN BJP >= AAP THEN BJP
ELSE AAP
END AS maxvote, Winner AS [Party Name] FROM TableName
Amit Arya18 reputationPosted Feb 7, 2014, 6:28 PM EST
now I want (maxvote-Win by) after doing that i will get the against party votes, I want that party name too
expected result: