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


i got the result this by using this query


SQL
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



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

expect result is:
HTML
Againstvote  AgainstPartyName
26929           AAP
24569           BJP
Posted
Updated 8-Feb-14 3:49am
v5
Comments
King Fisher 7-Feb-14 4:32am    
show your Table Structure
Amit K Arya 7-Feb-14 11:05am    
hi, King_Fisher, now take a look on table structure and plz suggest me.
gvprabu 11-Feb-14 6:07am    
how many columns you have in this table like BJP,AAP and ext...? or only two or three colums

1 solution

select winner using reverse condition same as you make avobe
 
Share this answer
 

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