Subject | Limiting Record Count |
---|---|
Author | ibrahim Bulut |
Post date | 2002-04-12T13:06:05Z |
Hi all,
I have got a new idea.
I want to share my idea with mail group.
Sometimes,
A lot of records fetch from query.
But we want first 10 record.
I didn't do it.
I asked this problem to mail group, my friends.
But I couldn't do it.
Some of myfriends (They are using Ms Sql Server) told me try following sql
statement
SELECT TOP 5 * FROM TABLE
This sql statement fetchs only first 5 record from table1.
But I couldn't do it with interbase.
We can do it with this way in interbase.
Create a TEMP generator.
Before Execute sql statement set generator's value to 0
SET GENERATOR TEMP TO 0;
And add this statement to where clause
(GEN_ID(TEMP,1) < 100)
Example
I want first 100 records from my table
SET GENERATOR TEMP TO 0;
SELECT * FROM TABLE1
WHERE (GEN_ID(TEMP,1) <= 100)
another example
SET GENERATOR TEMP TO 0;
SELECT * FROM TABLE1
WHERE (FIELD1 BETWEEN '01.01.2001' AND '31.12.2001') AND
(FIELD2 STARTING '100')
if I execute this statement 1500 records will fetch, but I want first 100
record.
I can do it with this statement
SET GENERATOR TEMP TO 0;
SELECT * FROM TABLE1
WHERE (FIELD1 BETWEEN '01.01.2001' AND '31.12.2001') AND
(FIELD2 STARTING '100') and (GEN_ID(TEMP,1) <= 100)
Ibrahim Bulut
Software Developer
Republic of Turkey
I have got a new idea.
I want to share my idea with mail group.
Sometimes,
A lot of records fetch from query.
But we want first 10 record.
I didn't do it.
I asked this problem to mail group, my friends.
But I couldn't do it.
Some of myfriends (They are using Ms Sql Server) told me try following sql
statement
SELECT TOP 5 * FROM TABLE
This sql statement fetchs only first 5 record from table1.
But I couldn't do it with interbase.
We can do it with this way in interbase.
Create a TEMP generator.
Before Execute sql statement set generator's value to 0
SET GENERATOR TEMP TO 0;
And add this statement to where clause
(GEN_ID(TEMP,1) < 100)
Example
I want first 100 records from my table
SET GENERATOR TEMP TO 0;
SELECT * FROM TABLE1
WHERE (GEN_ID(TEMP,1) <= 100)
another example
SET GENERATOR TEMP TO 0;
SELECT * FROM TABLE1
WHERE (FIELD1 BETWEEN '01.01.2001' AND '31.12.2001') AND
(FIELD2 STARTING '100')
if I execute this statement 1500 records will fetch, but I want first 100
record.
I can do it with this statement
SET GENERATOR TEMP TO 0;
SELECT * FROM TABLE1
WHERE (FIELD1 BETWEEN '01.01.2001' AND '31.12.2001') AND
(FIELD2 STARTING '100') and (GEN_ID(TEMP,1) <= 100)
Ibrahim Bulut
Software Developer
Republic of Turkey