how to find the particular row in table?(means suppose one
table contain 10 rows , in these 10 rows how to find the
particular row(example in 10 rows i want 5 row how)?

Answers were Sorted based on User's Feedback



how to find the particular row in table?(means suppose one table contain 10 rows , in these 10 row..

Answer / senthilkumar

SELECT TOP 1 Empid
FROM (SELECT DISTINCT TOP 6 Empid FROM Employees ORDER
BY Empid desc) a ORDER BY Empid asc

Is This Answer Correct ?    4 Yes 6 No

how to find the particular row in table?(means suppose one table contain 10 rows , in these 10 row..

Answer / vamsi krishna

select * from <table name> order by <column name> limit 0,5;
or
select * from <table name> limit 0,5;

Is This Answer Correct ?    1 Yes 3 No

how to find the particular row in table?(means suppose one table contain 10 rows , in these 10 row..

Answer / owen

-- I believe the questionner wants the 5th row
-- (only) from the data.
-- I also assume we don't have a useful ID to work with.
-- This is one way of doing it without cursors:

select top 1 <fieldname>
from <TableName>
where <fieldname> not in
(select top 5 <fieldname>
from <TableName>)

-- NB Changing the "5" in the subquery above sets which
-- row number is returned

Is This Answer Correct ?    0 Yes 2 No

how to find the particular row in table?(means suppose one table contain 10 rows , in these 10 row..

Answer / ashim pal

set rowcount 5

select * from table_name

Is This Answer Correct ?    7 Yes 16 No

how to find the particular row in table?(means suppose one table contain 10 rows , in these 10 row..

Answer / ritu saini

SELECT TOP 5 column FROM table
ORDER BY NEWID()

Is This Answer Correct ?    14 Yes 25 No

how to find the particular row in table?(means suppose one table contain 10 rows , in these 10 row..

Answer / sruthi

select top5 * from table
minus
select top4 from table

Is This Answer Correct ?    5 Yes 19 No

Post New Answer

More SQL Server Interview Questions

Explain DBCC?

0 Answers   QuestPond,


How do I port a number to sql server?

0 Answers  


Can truncate be rolled back?

0 Answers  


Hi SQL gurus, i am working for an MNC... My team is having a problem in sql server. when user slects date prompts from jan 1st to april 30, it should display all months data like : jan aa feb bb mar cc but when it comes to april its taking data like : jan aa feb bb mar cc apr dd...and so on means its taking data again from jan to april which we dont want. we want the data only april month as we are getting jan, feb and mar... can any one write the code to relsove the issue please would be greatful if you can send to shiva_sans@yahoo.co.in and also please send your email also ...so that we will be in touch for any kind of queries ... Thanks a lot in Advance !!!

1 Answers  


What is the stuff?

0 Answers  






What are the different SQL Server Versions you have worked on?

0 Answers  


Restore database SQL2000, SQL2012 Backup of base is created in Microsoft SQL Server 2000 - 8.00.2066, I can't restore on Microsoft SQL Server 2012 - 11.0.2100.60

3 Answers   IT Decisions,


How to maintain a fill factor in existing indexes?

0 Answers  


How do I start sql server?

0 Answers  


What meant by Performance Tuning,how can we do the performance tuning on stored procedures and tell some steps to do the performance tuning

3 Answers   TCS,


When should you use an instead of trigger?

0 Answers  


Call by value and call by reference in procedure and function, with NOCOPY.

0 Answers   Nagarro,


Categories