C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » Databases »

Retrieving the Specific Row ID Records of a Table.


Posted Date: 03 Aug 2004    Resource Type: Articles    Category: Databases
Author: K Hari PrasadMember Level: Gold    
Rating: 1 out of 5Points: 10



Introduction

This Article Explains how to retrieve the records of a Specific Row Id's
Suppose It can be 5 to 8.

i.e., Retreiving 5th Record to 8th Record irrespective of Column values.

Sample Data

EmpCodeVc EmpNameVc
These Two are VARCHAR Columns
0 John
13 Kalpana
15 Suchitha
17 Raj Kiran
2 Manjula
20 Rajesh Reddy
21 Vijay
22 Kamroddin
27 Vinod
28 Sunitha
29 Naga Kumari
30 Sujatha
31 Srinivas
32 Amaan
35 Naga Praveen
36 Avinash Rao
38 Praveen Kumar Reddy
4 Saritha
41 Zaki
42 Sunil
43 Naveen Kumar
5 Derrick
9 Nisha Mol

Query

SELECT *
FROM
(
SELECT TOP 4 * (No. of Records to be displayed)
FROM
(
SELECT TOP 8 * (Max of 5 and 8)
FROM Employee WHERE DeleteBt = 0
) a
ORDER BY a.EmpCodeVc DESC
) b
ORDER BY b.EmpCodeVc

// DeleteBt = 0 Displays All Working Employees


OUTPUT

2 Manjula
20 Rajesh Reddy
21 Vijay
22 Kamroddin



Responses

Author: venkat.Murthy    05 Aug 2004Member Level: Bronze   Points : 0



Author: venkat.Murthy    05 Aug 2004Member Level: Bronze   Points : 0
What is the role of DeleteBt in this query ?


Author: K Hari Prasad    05 Aug 2004Member Level: Gold   Points : 0
DeleteBt is of Type BIT

DeleteBt = 1 Display Resigned Employees
DeleteBt = 0 Display Presently working Employees




Author: pawan baheti    24 Aug 2004Member Level: Bronze   Points : 0
the query explained has three select commands which will take some time when dealing with larger databases. I think following query is better in performance

select top 8 * from where not in (select top 4 from )


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Getting a List of all the table Names created by the db USER
Previous Resource: Diffrence Between SQL Server and Oracle
Return to Discussion Resource Index
Post New Resource
Category: Databases


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use