dbTalk Databases Forums  

select specific rows in big select

comp.databases.sybase comp.databases.sybase


Discuss select specific rows in big select in the comp.databases.sybase forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
micro_goro
 
Posts: n/a

Default select specific rows in big select - 04-20-2004 , 07:08 AM







Hello all,

I am making a select from 5 big tables.
Select is ok but it takes time to get it.

The problem is that I need only specific rows from this select, I d
not use all of it. I use 1'st, 2'nd,... packs by 50.

I try to put the condition " WHERE identity(0) BETWEEN 50 AND 100
into my select but it replyes that

" statment contains an illegal usage of the NUMBER(*) function "

in oracle there are acceptable "rownum" in Where conditions

what is the analogue in Sybase anywhere 6-9 or Sybase IQ

or is it anyhow possible to select only these packs not selecting al
the table?

Thanks, To


-
micro_gor
-----------------------------------------------------------------------
Posted via http://www.webservertalk.co
-----------------------------------------------------------------------
View this thread: http://www.webservertalk.com/message188032.htm


Reply With Quote
  #2  
Old   
Michael Peppler
 
Posts: n/a

Default Re: select specific rows in big select - 04-21-2004 , 01:13 AM






On Tue, 20 Apr 2004 07:08:04 -0500, micro_goro wrote:

Quote:
Hello all,

I am making a select from 5 big tables. Select is ok but it takes time to
get it.

The problem is that I need only specific rows from this select, I do not
use all of it. I use 1'st, 2'nd,... packs by 50.

I try to put the condition " WHERE identity(0) BETWEEN 50 AND 100" into my
select but it replyes that

" statment contains an illegal usage of the NUMBER(*) function "

in oracle there are acceptable "rownum" in Where conditions

what is the analogue in Sybase anywhere 6-9 or Sybase IQ

or is it anyhow possible to select only these packs not selecting all the
table?
First - a database table is inherently UN-ordered: there is no first,
second, third row. To get the first 50 rows of a query you can use the
"set rowcount" option. To get rows 50-100 of a query you will have to use
a different technique.

One option is to do the following:

To get rows n-m from the table, first select rows 0-m into a temp table,
adding an identity column.
Then select rows from temp table where identity col between n and m.

This is not ideal, but it works.

There are also other techniques, depending on your data.

Michael
--
Michael Peppler Data Migrations, Inc.
mpeppler (AT) peppler (DOT) org http://www.peppler.org/
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or
long term contract positions - http://www.peppler.org/resume.html



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.