Re: sql query-help needed

Re: sql query-help needed

 

  

FETCH FIRST n ROWS - supported for V7 of DB2
SELECT *
FROM AA
FETCH FIRST 20 ROWS;


or

row_number() over function - supported for V8 of DB2

i.e.,

SELECT *
FROM (SELECT ROW_NUMBER() OVER() AS ROWNUM, * FROM S.A AA) AA
WHERE ROWNUM BETWEEN 5 AND 20; or FETCH FIRST 20 ROWS;


Toni Wielock
IT Senior Consultant
724-483-2287 - home
412-302-3628 - cellular
724-483-2445 - fax
t.[Email address protected]
[Email address protected]

----- Original Message -----
From: "Balamurugan Udhayakumar "
<db2udbdba-ezmlmshield-x90902250.[Email address protected]
To: "LazyDBA Discussion" <[Email address protected]
Sent: Friday, August 31, 2007 10:33 AM
Subject: sql query-help needed


>
>
>
> Hi everybody,
>
>
>
> I work in Db2 V8 and my OS is Z o/s.
>
>
>
> I have a doubt that in Oracle without knowing anything about records ,
> we can fetch a row by means of its rownum .
>
>
>
> For example :
>
>
>
> If we want to fetch the 5th row of a table we can do that by means the
> following query
>
>
>
> Select * from table where rownum = 5;
>
>
>
> I just want to know what we can use in db2 to fetch a row like what I
> have done in the above example.
>
>
>
> Could anyone help me out in the above scenario.
>
>
>
> regards,
>
> bala
>
>
>
>
>
> ============================================================================================================================
>
>
> Disclaimer:
>
> This message and the information contained herein is proprietary and
> confidential and subject to the Tech Mahindra policy statement, you may
> review the policy at <a
> href="http://www.techmahindra.com/Disclaimer.html">http://www.techmahindra.com/Disclaimer.html</a>
> externally and <a
> href="http://tim.techmahindra.com/Disclaimer.html">http://tim.techmahindra.com/Disclaimer.html</a>
> internally within Tech Mahindra.
>
> ============================================================================================================================
>
>
> ---------------------------------------------------------------------
> TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
> To post a dba job: http://jobs.lazydba.com
> To Subscribe : http://www.LazyDBA.com
> To unsubscribe: http://www.lazydba.com/unsubscribe.html
>


DB2 & UDB email list listserv db2-l LazyDBA home page