.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

select n-th item

Posted By:      Posted Date: September 15, 2010    Points: 0   Category :Sql Server
I would like to select the n-th item from a list. One way I know how to do it is like this. Please follow this example. Create a table and insert a bunch of integers in random order. create table A (col int) insert into A values (294) insert into A values (150) insert into A values (200) insert into A values (12) insert into A values (1000) insert into A values (56) insert into A values (750) insert into A values (62) insert into A values (560) If I want to select the N-th largerst number from table A, I can do this. (replace <N> with whatever number you want) select max(x.col) from ( (select top <N> col from A order by col) ) x So, if N = 5, then you should get 200 from the above example.   I'm looking for another way to do this using the rank() function. I know you can use rank() like this. select rank() over (order by col) num_rank, col from A But, how can I use num_rank column to get the N-th item. I tried something like this, but doesn't work. select rank() over (order by col) num_rank, col from A where rank() over (order by col) = 5  

View Complete Post

More Related Resource Links

On New Item form, select item on choice dropdown based on query result.


I posted this on Experts Exchange awhile back with no answer, so here's hoping someone here has an idea :)

So I've mostly figured this problem out, but I need some help in getting over the hump... note that I'm using JavaScript to do this (SPServices) on SharePoint 07'.

I'm on the New Items page of a list. Based on a user's selection in a "Teacher" dropdown, I'm doing the following:

1.) Get the value of the Teacher field and several other fields (School and Visit Date)
2.) Run a CAML query based on those fields to find the last list item entered for that Teacher

So here's where I'm stuck...

I have 10 choice fields, all with choices 0, 4, 7, and 10. Depending on what they were set to in the last entered item (which I queried), I want to set the selected item on each of those dropdowns to equal that. So "Score 1" was set to "4" on the la

Can't select combobox item with mouse

I have a bizarre issue with my wpf 3.5 app that I just wrote. One of the computers we installed it on won't allow the user to select an item from the combobox with the mouse. The mouse can make the drop down appear like normal, but when the mouse hovers over the items they are not highlighted and clicking on one closes the drop down but doesn't select the item. This is the default combobox with no style and only the margin, itemssource and selecteditem properties set. I tried other programs that have comboboxes (IE7, Excel, a VB6 app) and all of them work just fine. We have this program installed on numerous computers throughout our company and everyone else's is working correctly. I tried uninstalling the program and the .NET framework then reinstalling. I don't know what else to try.

CascadingDropdown Extender select item on pageload

I have a form that two cascadingdropdown extenders, when the page loads  the form is populated and cascadingdropdowns do work however the values should be set as the page loads.  I have tried setting the selectedvalue of the CDD but that doesn't take.   How do I set the values of the CDD with data from a db?

Problem Add Category Item by select department

Add Category Item by select department Firstly database has two tables Department and Category Department Table Id -------int  (PK) dep_name--------nvarchar(50) dep_description---------nvarchar(100) -------------------------------------------------------- Category Table Id------int cat_name------- nvarchar(50) cat_description----------- nvarchar(100) IsActive--------bit DepartmentId-----int   (FK) ---------------------------------------------------------- I have form contain DetailsView control under name CategoryDetailsView. My problem: this mechanism not duo correctly I don't know why,  only show to me when I run page" Procedure or function InsertCategory has too many arguments specified. " My idea when a user need to create category must on him write category details ( category name, Description, IsActive) and select this category where to insert by select department name from drop downlist This control connecting with table under name Category, insert process by stored procedure under name sp_InsertCategoryALTER Procedure [dbo].[InsertCategory] (@cat_name nvarchar(50) ,@cat_description nvarchar(100),@IsActive bit , @Result int output)AsBegin Insert Into Category (cat_name , cat_description, IsActive ) Values (@cat_name , @cat_description, @IsActive ) Select @Result = @@IdentityEnd <asp:DetailsView ID="CategoryDetailsView

Dropdown select message in item template gridview dropdwon list ???

Hi ....I have used gridview item template , which has two dropdown list .The first dropdown list is binded from database to the dropdown list I have using the below code , to show the select message in dropdown list before selecting any item from dropdown list.In first row its show me --Select-- message and my vaues.. if i select some value form dropdownlist and click add new button it will create a new row dynamic then in previous row again it come back --Select-- message... on going to second row....I need to remain first row user selected value on going to next row.The New row will show --select-- message..Please go to my code and let me know what to do<asp:DropDownList id="DropDonList2" tabIndex=11 runat="server"          OnSelectedIndexChanged="DropDonList2_SelectedIndexChanged" AutoPostBack="True"          DataTextField="SizeRange" DataValueField="SizeRange"          OnDataBound="DropDonList2_DataBound" __designer:wfdid="w10"          AppendDataBoundItems="True">  <asp:ListItem Value="-1">Select</asp:ListItem> </asp:DropDownList><asp:DropDownList id="DropDonList2" tabIndex=11 runat="server" 

Automatically select item with keyboard navigation in a combobox


Hi there,

in a WinForms ComboBox the selected item automatically changes, when I navigate through the combobox items with keyboard.

However, in the WPF ComboBox (IsEditable = false), the item in the list is highlighted but not automatically selected. Is there a way to change this behaviour?




How to select some part of a text in listview item?


Dear all

I have a listview in WPF application, that I bind data in it using gridview. now I want to make a search for it. making search is simple but question is this I want to make a search that if user type 'a' then system will highlight all 'a' in list view. or if user type 'lis' the system will highlight all 'lis' in that listview.

Is it possible to highlight part of the text in side of listview item? or I have to select whole listviewitme? 


Thank you so much

Select Item from Dropdownlist


I have a dropdown list created via MVCContrib FluentHTML - how do I perform a postback when the user selects any item in the dropdownlist? 

Select only one item through radi button in gridview


Hi friends i have a gridview with radio button.i need to select only one item through out gridview i have written code that is working fine but that is giving problem in paging i am displaying gridview with 5 records per page.in first page i am able to select only one item but if i move to second page here also i am able to select only one radio button in this mean time if move to first page in that page also radio button is in selected mode .How can i make only one radio button selected in through out gridview and How can i get paging data from gridview(if i select 3rd page value and i moved to first page in that situation i need to get get that 3rd page value aslo ).How can i get that data pls help me

Report viewer control is is displaying parameter item 'select a value' even when the default param



I am using SSRS 2008 R2,

I have set the default parameter of dropdown and in the output "select a value" item text is removed ,also in the Report Manager 'select a value' removed .

But when I am displaying the same reports in the ReportViewer control as ReportViewer1.ServerReport  in the the vs 2010 asp.net project the item select a value is reappearing in the output.

Could you please help me remove the default item text 'select a value' from the ReportViewer control aswel.


Dropdownlist postback always select first item


Hello, I am new at Asp.net. I hope some experts can help me.

I have 2 dropdownlist controls (ddl1 and ddl2). When I pick an item from ddl1, it will update ddl2. The problem is when I pick an item in ddl2, it always selects the first item in the list. Is it that the ddl2 autopostback causes the first ddl1 to reload and results the ddl2 to be refreshed also? Or I didn't set something correctly?

thanks in advance.


<asp:DropDownList ID="ddl1" runat="server" DataSourceID="sql

Nested ListView: Parent listview item auto selection on child ListViewitem select


how can i auto select paraten listview item on selecting child listview item?

ListView ItemContainerStyle="{StaticResource myStyle}" Name="lv_list" Margin="5" HorizontalContentAlignment="Stretch">

Pre-select item from newform.aspx


Hey forumers,

Got a quick question to ask y'all.

Lets say I have a item in a list called software. And lets say the items name is SharePoint.
When I open the Item I'll go to the basic Edit view, On the edit view I have added a button called "Add Media".
When I click on that button I'll go to the NewItem.aspx in my Media list.

Now my question is:
If i hit the "Add Media" button from any item (in the software list) I want that software item selected in the lookup field.

I have been looking at Workflows or Javascript to do this but I can't get it figured out.
Any ideas are really appreciated.

select listview item


Hi All.

I would like to select added ListView item in case when ListView has checkbox column.


 <DataTemplate x:Key="CheckBoxCell">
  <StackPanel Orientation="Horizontal">
   <CheckBox Name="chk" IsChecked="{Binding Path=IsSelected, RelativeSource={RelativeSou

Populate a dataGridview based on select an item in dropdownlist!


Hello all!

In window form,  there are two comboBoxs named cbo1, cbo2 with populate the same items in the dropdownlist as following: For examples,

Class A

Class B

Class C

I like to populate the data into two dataGridViews named dgv1, dgv2 based on selecting an item in two dropdownlists. The rules is if I select an item in the cbo1 to populate data in dgv1, and cbo2 with hide (remove) an selected item from cbo2 to avoid that the user selects the same item for populate the same data in the dgv2. In a brief, the displayed data in two dgv1, dgv2 are different. Any helps in C# code, I really appreciate it. Thanks in advance.

Listview & GridView , select an item




i create a ListView with a GridView and some GridViewColumn´s in therein:

<ListView ItemsSource="{Binding Records}" x:Name="list" Margin="21,8,21,18.9" Grid.Row="2" Background="{StaticResource linearbrush2}" HorizontalContentAlignment="Center">
      <GridViewColumn  DisplayMemberBinding="{Binding hd_drive}" Width="35" Header=" Drive"/>
      <GridViewColumn  DisplayMemberBinding="{Binding browser_name}" Width="100" Header="Browsername"/>
      <GridViewColumn x:Name="defaultbrowserpath" DisplayMemberBinding="{Binding file_path}" Width="300" Header="Path" /> 

the DisplayMemberBinding-Property points to a ObservableCollection, with the Name Records,

xmldatasource combined with enumerable to select value for currently displayed data item


This the XMl for my XMLdatasource

    <result name="response" numFound="3" start="0" maxScore="1.0">
    <arr name="themes">
    <str>Gemeente- en Stadhuis</str>
    <arr name="themes">
    <str>Gemeente- en Stadhuis</str>
    <str>Hoeve en Molen</str>
    <arr name="themes">
    <str>Kasteel en Landgoed</str>
    <str>Kerk en Klooster</str>

in my gridview RowDataBound event I have:

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend