Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
SQL
create table callRecords
(
srNo int identity(1,1),
mode varchar(20)
)
<pre lang="sql">
insert into callRecords values ('Email')
insert into callRecords values ('Telephone')
insert into callRecords values ('Others')
insert into callRecords values ('fax')
insert into callRecords values ('paper')

select * from callRecords
</pre>


output of above query is
srNo mode
1 Email
2 Telephone
3 Others
4 fax
5 paper


but i want that 'others' value at last of table even after further inserting values
srNo mode
1 Email
2 Telephone
3 fax
4 paper
5 Others

is there any way to do this ???
Posted
Comments
Arasappan 27-Aug-15 2:58am    
I thing u do this for dropdownlist ..Right..?
Member 11844168 27-Aug-15 3:11am    
yes right :-)
Arasappan 27-Aug-15 3:43am    
can i Give the solution..for dropdownlist not in sql...
Arasappan 27-Aug-15 3:45am    
If ur answer yes mean..show ur code to bind the data in C#..
Arasappan 27-Aug-15 3:49am    
or in sql..If u can put the other at first

1 solution

If i understand you well, you want to sort data. One of possible way is to use ORDER BY[^] clause.
SQL
SELECT *
FROM callRecords
ORDER BY CASE WHEN SrNo=3 THEN 1 ELSE 0 END, SrNo
 
Share this answer
 
Comments
Member 11844168 27-Aug-15 3:25am    
no
Maciej Los 27-Aug-15 3:27am    
No - what? Please, be more specific and provide more details.
Member 11844168 27-Aug-15 3:28am    
any of the further insertions ..the 'other' value should be at last row
Maciej Los 27-Aug-15 3:32am    
Impossible! because SrNo is identity column, which means that this field is automatically increased. To be able to achive such kind functionality you'll need to delete 'Other' value, then to insert new data and finally to insert 'Other' value again. Get it?
Member 11844168 27-Aug-15 3:29am    
like in dropdownlist...we have other value at last

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