SURESHKUMAR.NET FORUMS
Registered Member Login:
Not a member? Register today!



Welcome to the SURESHKUMAR.NET FORUMS.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.




to find last two items

        

Reply
 
LinkBack Thread Tools Display Modes
Old 07-06-07, 08:08 PM   #1 (permalink)
Junior Member
 
Join Date: Sep 2006
Age: 22
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 4 ashok.c is on a distinguished road
to find last two items

hi i m ashok
can anyone tell how to find the last two items in a field using sql server 2005

ashok.c is offline Offline   Reply With Quote
Old 08-06-07, 12:59 PM   #2 (permalink)
Junior Member
 
lakshmi.n's Avatar
 
Join Date: Jan 2007
Posts: 25
Thanks: 2
Thanked 9 Times in 6 Posts
Rep Power: 5 lakshmi.n will become famous soon enough lakshmi.n will become famous soon enough
Re: to find last two items

select top 2 column name from tablename order by columnname desc

or

select * from (select top 2 cname from tname
order by cname desc) a
order by cname


where cname=column name tname=tablename

i think its same query for sqlserver 2005 also
lakshmi.n is offline Offline   Reply With Quote
Old 04-09-07, 03:53 PM   #3 (permalink)
Junior Member
 
Join Date: Jun 2007
Age: 27
Posts: 22
Thanks: 4
Thanked 0 Times in 0 Posts
Rep Power: 3 ROBIN_signed is on a distinguished road
Re: to find last two items

select column_ name from table where table_id in(select max(table_id),max(table_id)-1, from table )

hope this helps also
alternative one for lakshmis query....
ROBIN_signed is offline Offline   Reply With Quote
Reply

Tags
items


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
TCS Pacement paper 20 sridhar TCS Placement Papers 0 12-02-07 05:38 PM
TCS Pacement paper 17 sridhar TCS Placement Papers 0 12-02-07 05:37 PM
TCS Pacement paper 1 sridhar TCS Placement Papers 0 12-02-07 05:27 PM
TCS PAPER & INTERVIEW - 23 JUN 2006 sridhar TCS Placement Papers 0 12-02-07 05:01 PM
Security researchers use search engine to find malicious code on the Internet wizkid SYSTEM SECURITY & ETHICAL HACKING 0 24-07-06 06:50 PM


All times are GMT +6.5. The time now is 07:48 PM.

More Interview Questions Here...

Content Relevant URLs by vBSEO 3.3.2