May 7, 2002 #1 ADB1 Programmer Joined Aug 24, 2001 Messages 235 Location GB Is there a function within sql to return a limited / snapshot number of rows when running a query. ie. the first 100 rows from a large table. Thanks, Adam.
Is there a function within sql to return a limited / snapshot number of rows when running a query. ie. the first 100 rows from a large table. Thanks, Adam.
May 7, 2002 #2 gregsimpson Programmer Joined Apr 18, 2002 Messages 521 It really depends on which RDBMS you are using. With DB2 you can append FETCH FIRST xxx ROWS ONLY to your select statement. With ORACLE you can append WHERE ROWNUM < xxx Others do it differently. Upvote 0 Downvote
It really depends on which RDBMS you are using. With DB2 you can append FETCH FIRST xxx ROWS ONLY to your select statement. With ORACLE you can append WHERE ROWNUM < xxx Others do it differently.
May 7, 2002 Thread starter #3 ADB1 Programmer Joined Aug 24, 2001 Messages 235 Location GB We are using Teradata. Upvote 0 Downvote
May 7, 2002 #4 gregsimpson Programmer Joined Apr 18, 2002 Messages 521 Follow this link into the teradata forum. More appropriate for your question. Looks like it has the answer for you. thread328-253753 Upvote 0 Downvote
Follow this link into the teradata forum. More appropriate for your question. Looks like it has the answer for you. thread328-253753
May 7, 2002 Thread starter #5 ADB1 Programmer Joined Aug 24, 2001 Messages 235 Location GB Thanks Greg. Adam. Upvote 0 Downvote
May 7, 2002 #6 KoopLaFez Programmer Joined May 7, 2002 Messages 3 Location US you can also use SELECT TOP 100 as your select statemnt. I'm not sure if the TOP keword is an ANSI standard or just in T-SQL though Upvote 0 Downvote
you can also use SELECT TOP 100 as your select statemnt. I'm not sure if the TOP keword is an ANSI standard or just in T-SQL though
May 11, 2002 #7 tdatgod Programmer Joined Jul 21, 2001 Messages 601 Location US Hi, We answered this question in the Teradata forum by suggesting SAMPLE. However this is the ANSI SQL forum so I guess that Begs the question. is there an ANSI way to limit the number of rows returned from a query? I mean if there is an ANSI way to do it than every RDBMS that is ANSI SQL compliant would support that method. Upvote 0 Downvote
Hi, We answered this question in the Teradata forum by suggesting SAMPLE. However this is the ANSI SQL forum so I guess that Begs the question. is there an ANSI way to limit the number of rows returned from a query? I mean if there is an ANSI way to do it than every RDBMS that is ANSI SQL compliant would support that method.
May 11, 2002 #8 karluk MIS Joined Nov 29, 1999 Messages 2,485 Location US Please read faq220-275 for an ANSI compliant solution. Upvote 0 Downvote
May 11, 2002 #9 tdatgod Programmer Joined Jul 21, 2001 Messages 601 Location US Hi, Thanks. I guess I will stick with vendor specific features for this since the performance of the FAQ example query would be pretty poor. It would cause 'n' passes over the table where 'n' is the number of entries you want returned. Thanks for the information. Upvote 0 Downvote
Hi, Thanks. I guess I will stick with vendor specific features for this since the performance of the FAQ example query would be pretty poor. It would cause 'n' passes over the table where 'n' is the number of entries you want returned. Thanks for the information.