fixed count of records

fixed count of records

Post by Mikalai Beliasho » Wed, 03 Mar 2004 17:15:01



I need to select top ten records. What should I do in my SELECT ?

--
with the best regards,
Mikalai Beliashou

 
 
 

fixed count of records

Post by David Porta » Wed, 03 Mar 2004 17:35:46


Top 10 what? Tables have no logical order so you need to base your
definition of "Top 10" on columns within the table. Here are two examples
from Pubs. Both use a key (au_id) to define the top 10.

SQL Server has a proprietary TOP modifier for SELECT statements:

SELECT TOP 10 *
 FROM Authors
 ORDER BY au_id

In ANSI SQL92 you can do this:

SELECT *
 FROM Authors AS A
 WHERE
  (SELECT COUNT(*)
   FROM Authors
   WHERE au_id <= A.au_id)
  <=10

--
David Portas
SQL Server MVP
--

 
 
 

fixed count of records

Post by Mikalai Beliasho » Wed, 03 Mar 2004 18:20:12


Thank you very much!

--
with the best regards,
Mikalai Beliashou


Quote:> Top 10 what? Tables have no logical order so you need to base your
> definition of "Top 10" on columns within the table. Here are two examples
> from Pubs. Both use a key (au_id) to define the top 10.

> SQL Server has a proprietary TOP modifier for SELECT statements:

> SELECT TOP 10 *
>  FROM Authors
>  ORDER BY au_id

> In ANSI SQL92 you can do this:

> SELECT *
>  FROM Authors AS A
>  WHERE
>   (SELECT COUNT(*)
>    FROM Authors
>    WHERE au_id <= A.au_id)
>   <=10

> --
> David Portas
> SQL Server MVP
> --

 
 
 

1. Question on bulk loading of fixed length/fixed field records

Hi all,

Is there any way using ASE 11.9 to load fixed form, char
data similar to the ASA 6.0 INPUT INTO command with the
COLUMN WIDTHS spec?  I'm new to ASE, and I noticed that
DBISQL has been replaced with ISQL, and the INPUT INTO
command no longer works.  I have looked at the doc for BCP,
but it looks like the fields have to be delimted and the
data I have to import to the database are all fixed field
records.

Thanks for any help anyone can provide.

Dwayne Butler
SPR Inc.

**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****

2. Crosstabs. Help!

3. using SELECT COUNT(*) to count distinct records

4. ODBC Failure with ORA-1013

5. Counting records with Count(*) AS

6. Collections/Array Question

7. Counting Records in Table not Connected to Records in Another (SQL Newbie)

8. Email addr to Persistance inc.

9. FMP5 Record Count of Found Record

10. combining records and determining record count

11. counting record only when field value is not equal to value of previous record

12. counting records only when value is different than previous record (MSSQL 2000)

13. extent count: fix me up