Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
i have a table :
HTML
Cong    BJP      AAP     Winner   Win By
25554   36985    26929   BJP      10056
19753   24569    36239   AAP      11670


HTML
declare @temptable table
(
Againstvote int
 
)
 

insert into @temptable select (CASE WHEN n_cong >= n_bjp AND n_cong >= n_aap THEN n_cong
                   WHEN n_bjp >= n_aap THEN n_bjp
                   ELSE n_aap
           END)-n_winby
 
            FROM m_assembly_election1993 order by n_winby desc
select Var1 from @temptable


i got the expected result by using this query

HTML
Againstvote
26929   
24569


All value of Againstvote column exist in my table as bold item.

Now I want column name of these values also

expected result is:

HTML
Againstvote  AgainstPartyName
26929           AAP
24569           BJP
Posted

1 solution

You already posted this question at How to solve this complex query?[^]. Please do not repost.
 
Share this answer
 
Comments
Amit K Arya 8-Feb-14 9:51am    
ok i have removed one, Please solve my query
Richard MacCutchan 8-Feb-14 10:17am    
You still have two open posts with the same basic question. Please follow the guidelines as described in Quick Answers FAQ.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900