SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Selecting records
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

tejokrishna
Starting Member

India
6 Posts

Posted - 02/11/2014 :  15:28:46  Show Profile  Reply with Quote
Hi,

Pls tell me ans for below questions:

1. How to select second row of particular table?

2. How to select alternate records of particular table?




Y.Tejo Krishna

shilpash
Posting Yak Master

103 Posts

Posted - 02/11/2014 :  17:42:34  Show Profile  Reply with Quote
1)lets say id is ur primary key)
SELECT TOP 1
*
FROM tablename
WHERE id NOT IN ( SELECT TOP 1
*
FROM tablename )
2)alternate rows---
SELECT *
FROM ( SELECT id ,
RANK() OVER ( ORDER BY id ) rn
FROM tablename
) t
WHERE ( t.rn % 2 = 0 )

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000