Re: sql - first 10 records
Posted in 1995
> Any ideas on how to get the first 10 records of a table/rec using > only sql/isql. table a > [...] > 1)can't use 10 + first no - may be gaps in numbering > 2)can't use 10 + first rowid - may be gaps in numbering > Any ideas. > Thanks. > Bob You could use an ACE report. ACE has the variables you can use to keep up with which row number is what. ACE is part of the I-SQL product set. Some thoughts on the way you phrased your question: "...the first 10 records of a table..." is an unusual way to put it. You might be interested in the "earliest 10 records sorted by date", or the "10 records with the lowest/highest value", or some such. Once you phrase the query in this way you free yourself from problems with rowid or gaps in numbering. Now that we need 10 rows based on some data-driven criteria we need an index on those criteria. Indexing will greatly speed your queries. Build it after you have re-phrased your query, and the columns to use for the index will suggest themselves. Lastly, consider other products besides I-SQL, too. When you begin to manipulate your data in this way you can realize cost savings over the package price by using I-4GL, client-server tools, or E-SQL. Verbosely, __________________________________________________________________ | Clem Akins Standard Disclaimers Apply | |Reynolds Metals Co, Alloys Plant "Climb High, Cave Deep!" | | Muscle Shoals, Alabama USA cwakins@leia.alloys.rmc.com | |________________________________________________________________|