How can I get row number in sql select?

Hi, all.

How can I get row numbers in select statement? For example, I have a sql
like:

  select emp_id, emp_name, emp_salary
    from employee
order by emp_id

Now, I want to add row numbers in the result set.

I know we can add a getrow() expression in datawindow, but I do want to know
how to do this in select statement.

I'm using sybase 11.0.2, pb6.

Best regards.

Feng





0
Feng
10/26/1998 1:42:15 AM
sybase.powerbuilder.general 62418 articles. 13 followers. Follow

2 Replies
1429 Views

Similar Articles

[PageSpeed] 12

This works in Sybase SQL Anywhere, I'm not sure whether it'll work in
Sybase 11.0.2

select number(*), emp_id, emp_name, emp_salary
from employee
order by emp_id

Feng Zhu wrote:
> 
> Hi, all.
> 
> How can I get row numbers in select statement? For example, I have a sql
> like:
> 
>   select emp_id, emp_name, emp_salary
>     from employee
> order by emp_id
> 
> Now, I want to add row numbers in the result set.
> 
> I know we can add a getrow() expression in datawindow, but I do want to know
> how to do this in select statement.
> 
> I'm using sybase 11.0.2, pb6.
> 
> Best regards.
> 
> Feng
0
howl
10/26/1998 3:47:14 AM
howl,

Sybase 11.0.2 does not provide such a function like number(*) in sql
anywhere, :-(

Feng


howl wrote in message <3633F0C2.5FA4@pacific.net.ph>...
>This works in Sybase SQL Anywhere, I'm not sure whether it'll work in
>Sybase 11.0.2
>
>select number(*), emp_id, emp_name, emp_salary
>from employee
>order by emp_id
>



0
Feng
10/26/1998 5:52:02 AM
Reply:

Similar Artilces:

How to set the row number and get the row number for ("selected row) in Datagrid
I face a problem that i can't get the selected row of the datagrid in both server side script (VB.net) and client side script (javascript) As i can't use the button column / hyperlink column in the datagrid. Thus , i need to handle the change the background color of the selected row and also to get the selected row number for Update/Delete. Thanks in advance. This depends on how do you perform the selection. Do you want to implement chaning of the SelectedRow at the client side without any postback? If you have no issues with postback, then you can do s little trick here: 1. ...

How can i write select sql command with random selected number
  I have member table with several records. I want write sql statement to select one of member from member table. that member should come randomly selected member is. like this select * from member where memberid= randomMemberIdHow can i create  randomMemberId?http://www.odesk.com/users/ASP-NET-Web-application-Designer-DotNetNuke-Expert_~~4fc245f3b8e64e9b SELECT TOP 1 columnList FROM member ORDER BY NEWID()Limno...

get row number in a sql
Hi, In ASE 12.0 version,how can I get a sequal row number in a single sql? If the sql is: select DeptID,DeptName from Departments I hope the result set is: sequal no dept id dept name 1 101 Finance 2 102 Human 3 103 IT 4 104 Sale Regards, Michael Zhao How about: select identity(32) as "sequal_no", DeptID, DeptName into #foobar from Departments select * from #foobar order by sequal_no drop table #foobar Michael Zhao wrote: > > Hi, > In ASE 12.0 version,how can I get a sequal row numb...

How to get selected rows in Powerbuilder
Greetings All, Using PB 9.0.3. I have a window that has 1 datawindow on it. This datawindow is being populated with data to serve as a "email" type system. I need the user to be able to highlight rows and then delete all rows they chose. So far I have been unsuccessful trying to get information on the selected rows. I am currently using: dw_1.Object.Data.Selected to try to get the information, but am getting the following error: Error: Non-array expected in ANY variable at line 2 in clicked event of object cb_1 of w_inboxdel. string setting setting = dw_1.Object.Da...

getting the row number of a selected checkbox
hi, i've been trying to do this in so many ways. please correct my code: this code goes over the rows and retrieves data from the other cells according to the selected checkboxes but i'm stuck as far as knowing the row number in which the selection was made. 10x.   protected void GetSlection_Click(object sender, EventArgs e) { foreach (GridViewRow gvr in booksTable.Rows) { CheckBox chkSelect = gvr.FindControl("chkSelect") as CheckBox; int NumberOfResults = booksTable.Rows.Count; int NumberOfCells...

how can I get row number of datawindow?
I need Process row number of datawindow.which function can I use? thank you. <dw_name>.RowCount() will give you the number of rows. Hi, You use the function GETROW() of datawindow control. Hope this help. brgrds. Jimar ...

HOW TO GET THE SELECTED GRIDVIEW ROW NUMBER ?
Hi Friends ! (VB.NET)  JUST I SHOW MY SAMPLE CODE . MY PROBLEM IS I WANT TO GET THE SELECTED GRIDVIEW ROW NUMBER. PLS TELL ME HOW TO GET THE SELECTED ROWNUMBER INSIDE THE TEXTCHANGE EVENT   protected Sub EcodeTxt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) For Each row In GridView1.Rows Next End Sub   THANKS  GK        You could put an attribute on your textbox with the gridviewrow rownumber during the gridview's row databound event and reference it when needed in your text box's text cha...

How I can select limitet numbers of rows
How I can set limit and offset on select query? I need select 20 rows starting from 40 row SET ROWCOUNT 20 /* This will limit the number ow rows returned to 20 */ SELECT * FROM Table WHERE KeyColumn (s) > [Value of 20th key you got earlier] /* Hopefully you understand this pseudo code...*/ ORDER BY KeyColumn (s) Notes: 1. Reomve the WHERE clause when fetching rows for the very 1st time 2. Reverse the ORDER BY when doing a "Prev. Page" scrolling and change the '>' to '<', plugging the correct key value webmaster@priorbank.by wrote: >...

Get number of rows from select statement
AllI'm trying to write a check before setting a value in my SQL code. Below is my code for the checkSELECT charge FROM BILLING_STATUS WHERE CLIENT_CODE='BOSI'AND DATEPART(Q, BILL_DATE) = 1 AND DATEDIFF(yyyy, BILL_DATE, GETDATE()) = 0 GROUP BY charge It's returning the following charges, which is correct...1 .0302 .040However, I need to know how many charges there are with different values i.e. in example above there are two different charge values. If the results were .30, .40, .50. 60, .70 I would 5 to be returned, etc. Anyone have any ideas? p.s. I've tried SUM, CO...

Oracle SQL select for getting groups of rows?
Hi , I am using Oarcle 7.3.4. I am selecting rows from a table into a datawindow at 100 rows at a time from a table that has 1 million + rows. I need to retireve the rows in a sorted manner - Select col1, col2, etc. from table order by col1. How can I create sql that will retrieve into my datawindow, in a sorted manner, at 100 rows at a time? Any suggestions on how to create this SQL would be greatly appreciated. TIA Marc Marc, Assume that Col1 is the primary key of the table. Declare an instance variable: long il_Col1=0 In the RetrieveRow event: If row >= 1...

how i can get Current row number of Datawindowchild....
Hi Everybody, Is somebody can tell me how i can get Current row number of Datawindowchild and how i can select the current row of the Datawindowchild. Thanks, Noaman Mughal Somebody already did. There is no need to repost the same question. "Noaman Mughal" <nomi_mughal@hotmail.com> wrote in message news:eIP0ToCNDHA.279@forums-2-dub... > Hi Everybody, > > Is somebody can tell me how i can get Current row number of Datawindowchild > and how i can select the current row of the Datawindowchild. > > Thanks, > Noaman Mughal > ...

how to get serial number of row in select clause
i want to get sr. no. as one column in select clause, i know with row_number () over() , it is possible, but in over we have to define order by some field, that i dont want is there another way to get that. thanksVISHAL PAREKH if you table don't have any identity column then,  select identity(int) as sl,* INTo #temp FROM dbo.MM_MaterialGroups SELECT * FROM #tempif your table has  identity column, then use row_number function with tableid as order by parameter.  Give a man a fish and you feed him for a day. Teach a man to fish and you feed him forever. ...

how i can get current row number of datawindowchild...
Hi Everybody, Is somebody can tell me how i can get Current row number of Datawindowchild and how i can select the current row of the Datawindowchild. Thanks, Noaman Mughal Do a Find on the DWC, searching for the value of the parent column in the code column of the DDDW. To "select" a row in a DDDW, set the value of the parent column to the appropriate value from the code column of the DDDW. "Noaman Mughal" <nomi_mughal@hotmail.com> wrote in message news:uK6nVWCNDHA.349@forums-2-dub... > Hi Everybody, > > Is somebody can tell me how i...

How can I get the number of rows of tabpages on a tab
Hi all, we have the problem, that we have to get the number of rows of tabpages on a tab at runtime. If a user resizes the window the number of rows can vary. Regards Christian Freund Can you explain what you need this for? Is this a resize logic issue? -- <hopethishelps/> Roy Kiesler [TeamSybase] SDN CodeXchange -- http://codexchange.sybase.com "Christian Freund" <freund@sf-datentechnik.de> wrote in message news:%23IPjeyxPDHA.81@forums-2-dub... > Hi all, > > we have the problem, that we have to get the number of rows of tabpages on ...

How to get the index of each row from a SELECT query in SQL ?
Hi,I am making as SELECT query to fill a repeater, and I need to retrieve the index of each line of the query.ie, I want to get a dataset like :"0", "dataCol1", "dataCol2" for the first line"1", "dataCol1", "dataCol2" for the second line"2", "dataCol1", "dataCol2" for the third lineetc.Anyone knows if there is a sql statement that does it ?ThanksJohannWebsite - Weblog check this***********************Dinakar NethiLife is short. Enjoy it.*********************** You can also create a temp table with an int identity column, insert the first table into the temp, and retur...

without using SQL, can i select distinct row??
as title, i want to select distinct row in a column. (I know how to do in writing a SQL, select distinct colname from table) but i don't want to hit the database again, so can i get it directly from dataView/DataReader/Datagrid???how? thank you for your help~~~~~~~~~~~ Take a look @ HOW TO: Implement a DataSet SELECT DISTINCT Helper Class in Visual C# .NETSushila Bowalekar PatelVisual ASP/ASP.NET MVPhttp://weblogs.asp.net/sushilasb...

can I get the number of table rows outside a table?
 Hi all,in my report I have a table based on a dataset. the table has a filter so it displays less records than the total number of records from the dataset.Depending on the number of rows I want to display different textboxes below the table. In the visible-attribute of the text box I would like to use something like that:=iff( <number of rows in the table> <= 5, true, false).Thank you for any help in advance.Dieter I think you should go with GridView instead of your Table.you can get the number of Rows from the DatasetDS.Tables(0).rows.count Please Mark as Answred If ...

how to select a virtual row of numbers to work with it in SQL statement?
hi, i' m trying to find a way to get a free number for pk in a table. if tried to select "select number(*) nr from BIGTABLE, BIGTABLE x", but i cant say where nr not in MYTABLE. i guess everybody knows that this is not allowed. does anybody know an alternative way to select a free number? pls not (isnull(max(nr),-1)+1) :) thnx and regards, stephan. The best way is DEFAULT AUTOINCREMENT. It's fast, it's reliable, and it doesn't cause concurrency problems. Breck On 15 Feb 2004 22:28:27 -0800, "Stephan Ahlf" <ahlf@svs.de> wrote: ...

How to get Row Numbers from SQL Express 2005 query?
 Hi,  I'm using SQL Express 2005 and VIsual Studio 2005, and this sounds like it should be easy. I'm trying to return the row numbers of my queries, but if I use the Row_Number() command I get the following error: "The OVER SQL construct or statement is not supported." So, is Row_Number() not supported in SQL Express 2005? If not, how can I return row numbers with my queries? Or, more specifically, how can I return a limited result set from a query (i.e. Return only row number 10-20)? My current command is as follows:  SELECT (SELECT R...

Get the Row Number or Row ID
Hi, I am using Sybase Central v4.3 with Interactive SQL to query the SQL Commands. My concern is how to get the rownumber or row id in select queries. Is there any in built commands in the ASE. If not please suggest me how to get the rownumber. Thanks.... Unless i'm mistaken, ASE does not use a rowid... it can have a timestamp, but it is updated with every modification to the row. http://infocenter.sybase.com/help/topic/com.sybase.help.ase_15.0.blocks/html/blocks/blocks34.htm -- Cory Sane [TeamSybase] Certified Sybase Associate DBA for ASE 15.0 "Santhanam P" wrote in message news:4b84baa8.6faf.1681692777@sybase.com... > Hi, > I am using Sybase Central v4.3 with Interactive SQL to query > the SQL Commands. My concern is how to get the rownumber or > row id in select queries. Is there any in built commands in > the ASE. If not please suggest me how to get the rownumber. > Thanks.... On 2/23/2010 10:35 PM, Santhanam P wrote: > Hi, > I am using Sybase Central v4.3 with Interactive SQL to query > the SQL Commands. My concern is how to get the rownumber or > row id in select queries. Is there any in built commands in > the ASE. If not please suggest me how to get the rownumber. > Thanks.... There is no rownumber concept per se (although the DOL lock scheme has a concept of a fixed row id, which consists of the combination of page number and row number on the page - but isn't particularly usefu...

Get row number/index that a dropdownlist selection was made on (Gridview)
I have a template field that has a dropdownlist in a gridview that has 10 rows. When the user changes the value of any of the dropdownlists i want to be able to find out which row the dropdownlist which was modified is on. I found some code on another site, so if you could help me understand that code or suggest something else that would be great.  Here is the code I found on another site but I get stuck with the last line,----------- THE CODE IN VB-----------  Dim dgi As DataGridItem = CType(ddl.Parent.Parent,DataGridItem) (or ddl.NamingContainer instead of ddl.Parent.Parent) ...

How can I process more than one row and get a new output number for each
I have the following stored procedure that first inserts a new receiptnumber into a numbercounter table and then uses that number in another insert for a payment. My problem is I'm only getting one new receiptnumber so if there are more than one payment in the second insert it fails because of a constraint on the payment table that will not let the same receiptnumber be used more than once. I need to Insert a new receiptnumber for each row in the second insert. How can I do this? @ReceiptNumber int OUTPUTASBEGININSERT INTO tblNumberCounter (InsertDate)Values (...

Can't get a Select count number form a dataset
Hi, I am trying to get the number from a query and cannot... Any ideas what I am doing wrong?  Please advise. Thanks, SELECT        COUNT(EMPLOYEE_ID) AS scoreTotalNumFROM            SCOREWHERE        (SEAT_ID = @SEAT_ID)  Substitue SEAT_ID 422 for @SEAT_ID yields: scoreTotalNumber = 50 Code in Question------------------------------ try {ScoreStatsTableAdapters.SCORETableAdapter ScoreTotalNum = new ScoreStatsTableAdapters.SCORETableAdapter();ScoreSt...

I can't get value of control in the selected row of a Gridview
I'm trying to perform an update using a sqldatasource from a gridview after a selection is made from a dropdown and a linkbutton "lbnUpdate" is clicked. I assigned  "select" as the command name of the linkbutton so I was assuming that I could then reference the gridviews selected row from the code behind but I guess I made a bad assumption. During debug there is "nothing" in the variable I use to capture the gridview selected row. I will post what I have. If I set AutoGenereateSelect button to true I can get the SelectedIndexChanged event...

Web resources about - How can I get row number in sql select? - sybase.powerbuilder.general

Welsh Affairs Select Committee - Wikipedia, the free encyclopedia
The Welsh Affairs Select Committee (or simply the 'Welsh Affairs Committee') is a select committee of the House of Commons in the Parliament ...

kotaku selects
Kotaku Selects

Here They Come: Facebook Announces Premium Video Ads From ‘Select Group Of Advertisers’
Facebook video ads have finally arrived, at least for a “select group of advertisers,” as the social network announced the launch of what it ...

Select Harvests says it can weather almond price plunge
Select Harvests, Australia's biggest almond producer, says it has a strong enough balance sheet to weather volatility in the market.

Instagram rolling out multiple account support to select iOS users
... news on Apps , iOS , and iOS continue reading at 9to5Mac . What do you think? Discuss "Instagram rolling out multiple account support to select ...

AMD to Bundle New Hitman Game with Select FX CPUs and Radeon 390 Series Video Cards
AMD announced this week that it will bundle the full version of the new Hitman game with its Radeon R9 390-series graphics cards as well as FX ...

50% off in-app purchases for select Google Play Games
... is working for you in the comments, and let us know what part of the world you’re checking it from. Also, tell us what you think of this selection ...

Deals: $40-$50 off iPad mini 4, $200-$300 off select 2015 MacBook Pros
This week, Apple authorized resellers have marked down a selection of 16GB-128GB iPad mini 4s by $40 to $50. Meanwhile, big discounts are popping ...

"Select, Do Not Settle"
By Dan from New York When I was a kid growing up in NYC, a big men’s clothing store (Barney’s) used this as its tagline: “Select, Don’t Settle.” ...

Oddisee, OSHUN & Tunji Ige played BrooklynVegan-Red Bull Sound Select at Baby's All Right
... / OSHUN / Tunji Ige @ Baby's All Right - 1/19/15 Oddisee headlined Tuesday night's BrooklynVegan-curated installment of Red Bull Sound Select ...

Resources last updated: 2/18/2016 5:20:34 AM