I want to select top 3 rows except the first from 4 rows of a Table. It should select from top 2 row,top3 row and top4 row.

 Hi,

 

Let say I've 4 rows in a table.

 I want to select top 3 rows except the first from 4 rows of a Table. It should select from top 2 row,top3 row and top4 row.

 

Thanks in advance
Asghar Ali Mohammed
http://www.aliwebdev.com
(Web Designer and Developer)


Do not forget to "MARK AS ANSWER" on the post that helped you.
0
mohdasghar_ali
6/26/2008 12:50:37 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

6 Replies
1012 Views

Similar Articles

[PageSpeed] 40

If you can use Linq, you can use Skip.

http://msdn.microsoft.com/en-us/vcsharp/aa336757.aspx


Thanks, Ed

Microsoft MVP - ASP/ASP.NET

0
ecbruck
6/26/2008 1:01:18 PM

Hii dear..

U can fire the Query select Top(3) from Table1 order by id desc.. 


"A conclusion is where you got tired of thinking.
Be different. Think "

Remember to click “Mark as Answer” on the post If you get answer from my post(s) !

Thanks Guys
------------
Pushkar
0
Pushkar
6/26/2008 1:07:33 PM

 When i fire Query  like this

SELECT top(3) FROM [Table] ORDER BY  DESC .

It will Select Top 3 rows but I want to ignore first top row and select from second row, 2,3,4

 

I hope you understood

 

Thanks in advance 


Asghar Ali Mohammed
http://www.aliwebdev.com
(Web Designer and Developer)


Do not forget to "MARK AS ANSWER" on the post that helped you.
0
mohdasghar_ali
6/26/2008 1:18:58 PM

 Remove Desc from the Query...

Still not getting the result please post your record as shown in the result when u fire the Query in the DB Query command... 


"A conclusion is where you got tired of thinking.
Be different. Think "

Remember to click “Mark as Answer” on the post If you get answer from my post(s) !

Thanks Guys
------------
Pushkar
0
Pushkar
6/26/2008 1:23:00 PM

If want to select top 3 rows from a database. I can do this by this command:  SELECT top(3)* from [TableName] order by [News_Id] Desc; It will select top 3 rows.

But Here I want to select 3 rows from the top but i do not want to select first row. I want to select from 2nd row, 3rd Row and 4th row only.

 


Asghar Ali Mohammed
http://www.aliwebdev.com
(Web Designer and Developer)


Do not forget to "MARK AS ANSWER" on the post that helped you.
0
mohdasghar_ali
6/26/2008 1:44:26 PM

If this helps you, this is what is generated by a SKIP call i Linq for retrieving all rows of the Northwind.Products table except for the first row: 

{SELECT [t1].[ProductID], [t1].[ProductName], [t1].[SupplierID], [t1].[CategoryID], [t1].[QuantityPerUnit], [t1].[UnitPrice], [t1].[UnitsInStock], [t1].[UnitsOnOrder], [t1].[ReorderLevel], [t1].[Discontinued]
FROM (
    SELECT ROW_NUMBER() OVER (ORDER BY [t0].[ProductID], [t0].[ProductName], [t0].[SupplierID], [t0].[CategoryID], [t0].[QuantityPerUnit], [t0].[UnitPrice], [t0].[UnitsInStock], [t0].[UnitsOnOrder], [t0].[ReorderLevel], [t0].[Discontinued]) AS [ROW_NUMBER], [t0].[ProductID], [t0].[ProductName], [t0].[SupplierID], [t0].[CategoryID], [t0].[QuantityPerUnit], [t0].[UnitPrice], [t0].[UnitsInStock], [t0].[UnitsOnOrder], [t0].[ReorderLevel], [t0].[Discontinued]
    FROM [dbo].[Products] AS [t0]
    ) AS [t1]
WHERE [t1].[ROW_NUMBER] > @p0
ORDER BY [t1].[ROW_NUMBER]
}

Thanks, Ed

Microsoft MVP - ASP/ASP.NET

0
ecbruck
6/26/2008 2:06:25 PM
Reply:

Similar Artilces:

First Row, Next Row, Prior Row, Last Row
I have a SQL Anywhere 7.0 Database, have a table Product_detail which contains Column Name Datatype width Null Default batch_id char(10) No None prod_id Integer No None employee_id Integer No None quantity Integer No None price Numeric (14, 2) No None Its primary key is batch_id I have a Freeform Datawindow with this table I want to provide the first row, next row, prior row and last row Ho...

how to select first row or first 3 rows from my database with linq?
Hi, I am trying to retrieve the latest record from my database. have created a repeater and it works just fine selecting all the data from the db with: protected void Page_Load(object sender, EventArgs e) {MMDataContext db = new MMDataContext(strConnection);var qvote = from vote in db.Votes                 orderby vote.VoteDate descending                 select vote; Repeater1.DataSource = qvote;Repeater1.DataBind();} How to...

Gridview paging enabled. Has checkbox to select the row . If user select the checkbox on one page and move to 2nd page to select the rows there also to export the selected rows to excel. But doing so
HiI am using Gridview and that has paging enabled. Using checkbox to select the particular row of the gridview to export the selected rows to the excel . Everything is working fine except for one case.Let user selected the "check" box for, five rows which user would like to export to excel (two of rows on page 1 of results and 3 of them on page 2 of results), however it only exports the 3 row details from page 2, because it seems to de-select the 2 rows from page 1 when I move to page 2 and vice versa. The code i am using is as :protected void BtnExcel_Click(object sender, EventArg...

Select rows from a table based on multiple rows of another table #4
I am working in a database associated with our scheduling package and I am trying to select rows in one table based on multiple rows in another table how ca I do this. Here is an example. ...

Select rows from a table based on multiple rows of another table #3
I am working in a database associated with our scheduling package and I am trying to select rows in one table based on multiple rows in another table how ca I do this. Here is an example. ...

Select rows from a table based on multiple rows of another table #2
I am working in a database associated with our scheduling package and I am trying to select rows in one table based on multiple rows in another table how ca I do this. Here is an example. Sorry technical problems! I am working in a database associated with our scheduling package and I am trying to select rows in one table based on multiple rows in another table how ca I do this. Here is an example. I have a table which holds all of my project info and I have another table which holds discriptive project codes like project type, project category, progect life cycle.So in the pro...

ADO.net problem: i can not view image data for the rest of my table rows except the image for the first row but i can read all the other non image fields for all rows.
Hi i have a table with the following fields imgid............int imgdata........image imgtitle.........varchar(max) imgType........varchar(max) imgLength.....bigint incident_id.....int i have no problem with uploading the image but viewing the uploaded image(s) in a gridview has caused me great pain. The probelm is i have two pages. page1 grabs the image to display and page2 has a gridview that displays the grabed image. I wanted to have an sql statement like SELECT * FROM mytable WHERE incident_id=someValue. IF i have 5 records in this table and i view page2 ...

Selecting a gridview row and keeping the last selected row in a gridview highlighted after mouse moves over a new row.
What is the best way to show a gridview row highlighted once selected and keep it highlighted once the mouse moves over a different row? Thanks, Steve hi,you can use <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="#FFFFFF" /> plz let me know if i misunderstood you Thanks for your help. One problem; however, is that after the row has been selected and I check the "grid.SelectedIndex" it has a value of -1 and not the index of the row that was selected on the grid. What do you recommend? Thanks, Steve hi, sorry i din...

DataGrid Selected Row Moves To Top Row of Grid????
Hello all, I have a data grid with a link Button column Built in Property Builder (coding in C#). Problem: When a link button is clicked, the row that was selected moves to the top row of the data grid. I need to find a way to simply keep the row where it is and highlight it. I've tried to set the back color of the selectedItem in the Format section of the property builder but nothing happens. If I use a select button highlighting the row as mentioned above works fine but i need to use a link button. If I code the click event of a select button column to response.redirect(&q...

Select first row or last rows!
Dear experts: i would like to know how to fetch in an select statement the first 20 rows from 2 tables. I want to show first 20 the records from sales,members where sales>4000 thank you... "John Vai" <john_vai[at]hotmail[dot]com> wrote: > i would like to know how to fetch in an select statement the first 20 rows SELECT TOP 20 .... Adding ORDER BY is strongly recommended. Dmitri. This TOP 20 doesn't work for sybase , its works for MySQL and i've already tried it. I am using for the moment set rowcount 20 but there should be ...

Printing selected row/ rows
Well, I would like to have help or some direction, for printing single or multiple selected rows from datawindow. Hi, You have to code this yourself. You may want to check out the dw_1.object.datawindow.selected.data which returns you a string with the selected data. Use this data to fill a datastore with the same dataobject as your datawindow, using the importstring function. Then print the datastore. HTH -- - Met vriendelijke groet, Eric Aling [TeamPS], Cypres Informatisering bv, The Netherlands http://ourworld.compuserve.com/homepages/alingejj DK wrote in message ...

Select row on row click?
Hello, the problem is the following one.I have a gridview with a lot of options (6 options in total) that means 6 icons at the end of each row, its veryugly, I want to create a toolbar(its already created)  , I want that the row be selectable with a single click on any part of the row, and when the row is clicked then I will show the toolbar and the user would be able to select any of the 6 options. Can somebdy please tell me how can I make the row clickable and selectable, and how can I make from the toolbar buttons to know wich row is selected T...

how to hightlight a row when a row is selected?
 In a GridView, how to hightlight a row when a row is selected? I hope that one expert can give me that link for the famous 3-tier web application tutorial? Thanks. Refer this article....http://www.netomatix.com/development/gridviewrowselectedstyle.aspxHope it helps. Mark as Answer if it does. KAMMIEDon't forget to Mark as Answer on the post that helped you. It encourages them to share their knowledge, and it helps others to easily identify the solution. Here is an article that shows how to capture when a row is clicked on a GridView control: http://highoncoding.com/Articl...

Stored Procedure
I wish to select all post from Table Category and the first row in Product table. SQL goes (not working just to show you how im thinking): SELECT Category.CategoryID, Category.Title, TOP (1) Product.ImagePath, TOP (1)  Product.CategoryID FROM Category INNER JOIN Product ON Category.CategoryID = Product.CategoryID GROUP BY Category.CategoryID, Category.Title Thanks for your help!  SELECT Category.CategoryID, Category.Title, Product.ImagePath,   Product.CategoryID FROM Category crossJOIN (select top 1 * from  Product ) PGive a man a fish and you feed him for ...

Web resources about - I want to select top 3 rows except the first from 4 rows of a Table. It should select from top 2 row,top3 row and top4 row. - asp.net.presentation-controls

Resources last updated: 12/3/2015 12:29:27 AM