Discussion:
Returning only the last 'x' rows
(too old to reply)
Terry Dykstra [TeamSybase]
2009-06-16 03:49:46 UTC
Permalink
Assuming Oracle:

select * from (
Select tabl_a.*, tabl_b.*
From tabl_a, tabl_b
Where table_a.field_1 = table_b.field_1
Order By table_a.field_2 )
where rownum < x
--
Terry Dykstra (TeamSybase)
http://powerbuilder.codeXchange.sybase.com/
http://casexpress.sybase.com
product enhancement requests:
http://my.isug.com/cgi-bin/1/c/submit_enhancement
IM 10.5 Build 4523
What is the syntax to returning only the last 'x' rows for a
Select *
From tabl_a, tabl_b
Where table_a.field_1 = table_b.field_1
Order By table_a.field_2
The Order By field is the field I want to use for the
criteria of the "Last 'x' Rows"
Thanks
unknown
2009-06-16 04:56:41 UTC
Permalink
Sorry Terry - how about SQL Server?
Post by Terry Dykstra [TeamSybase]
select * from (
Select tabl_a.*, tabl_b.*
From tabl_a, tabl_b
Where table_a.field_1 = table_b.field_1
Order By table_a.field_2 )
where rownum < x
--
Terry Dykstra (TeamSybase)
http://powerbuilder.codeXchange.sybase.com/
http://casexpress.sybase.com
http://my.isug.com/cgi-bin/1/c/submit_enhancement
Build 4523
What is the syntax to returning only the last 'x' rows
Select *
From tabl_a, tabl_b
Where table_a.field_1 = table_b.field_1
Order By table_a.field_2
The Order By field is the field I want to use for the
criteria of the "Last 'x' Rows"
Thanks
Terry Dykstra [TeamSybase]
2009-06-16 19:14:33 UTC
Permalink
I'm not a SQL Server user, but Google is your friend in cases like this.
Using "sql server top 10" as search, randomly picked the first result:

http://www.databasejournal.com/features/mssql/article.php/3532226/TOP-Clause-in-SQL-Server-2005.htm
--
Terry Dykstra (TeamSybase)
http://powerbuilder.codeXchange.sybase.com/
http://casexpress.sybase.com
product enhancement requests:
http://my.isug.com/cgi-bin/1/c/submit_enhancement
Post by unknown
Sorry Terry - how about SQL Server?
Post by Terry Dykstra [TeamSybase]
select * from (
Select tabl_a.*, tabl_b.*
From tabl_a, tabl_b
Where table_a.field_1 = table_b.field_1
Order By table_a.field_2 )
where rownum < x
--
Terry Dykstra (TeamSybase)
http://powerbuilder.codeXchange.sybase.com/
http://casexpress.sybase.com
http://my.isug.com/cgi-bin/1/c/submit_enhancement
Build 4523
What is the syntax to returning only the last 'x' rows
Select *
From tabl_a, tabl_b
Where table_a.field_1 = table_b.field_1
Order By table_a.field_2
The Order By field is the field I want to use for the
criteria of the "Last 'x' Rows"
Thanks
Loading...