Thursday, 28 July 2016

Re: [firebird-support] how to get rownum

 

On 28-7-2016 04:49, 'hz.yb' hz.yb@foxmail.com [firebird-support] wrote:
>
>
> i want to get rownum?how to select?thanks
>
> table:
> CREATE TABLE PZ (
> ID INTEGER NOT NULL,
> RQ TIMESTAMP NOT NULL,
> JE DECIMAL(18,2),
> /* Keys */
> PRIMARY KEY (ID)
> );
>
> data:
> INSERT INTO PZ (ID, RQ, JE) VALUES (11, '2016-01-01 23:55:00', 84.38);
> INSERT INTO PZ (ID, RQ, JE) VALUES (12, '2016-01-02 23:55:00', 37.97);
>
> i want to get rownum(ORDER BY RQ),for example:
>
> ROWNUM ID RQ JE
> 1 11 2016-01-01 23:55:00 84.38
> 2 12 2016-01-02 23:55:00 37.97
>
> HOW TO SELECT?

You need Firebird 3, and use ROW_NUMBER(), see also the Firebird 3
release notes
http://www.firebirdsql.org/file/documentation/release_notes/html/en/3_0/rnfb30-dml-windowfuncs.html#d0e5417

example

select row_number() over() as rownum, id, rq, je from pz

Mark
--
Mark Rotteveel

__._,_.___

Posted by: Mark Rotteveel <mark@lawinegevaar.nl>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

Save time and get your email on the go with the Yahoo Mail app
Get the beautifully designed, lighting fast, and easy-to-use Yahoo Mail today. Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

.

__,_._,___

No comments:

Post a Comment