Contar registros

Contar registros

Postby acuellar » Mon Jul 18, 2011 12:48 pm

Hola amigos

Que funcion cuenta los registros de una base filtrada con Scope

He intentado con Recount(), (dbGoBottom(),Recno())

El resultado es todos los registros.

Gracias por la ayuda

Saludos,

Adhemar
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1599
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Contar registros

Postby Patricio Avalos Aguirre » Mon Jul 18, 2011 1:27 pm

Hola

Si utilizas ADS, la funcion es

Code: Select all  Expand view
adsKeyNo( ,, 3 ) )
Saludos
Patricio

__________________________________________________________________
Version: Harbour 3.2.0dev (r1307082134),Compiler: Borland C++ 5.8.2 (32-bit)
PCode version: 0.3, FWH 13.2
http://www.sialm.cl
User avatar
Patricio Avalos Aguirre
 
Posts: 1060
Joined: Fri Oct 07, 2005 1:56 pm
Location: La Serena, Chile

Re: Contar registros

Postby acuellar » Mon Jul 18, 2011 1:36 pm

Gracias Patricio

Lo solucioné con
dbGoBottom()
OrdKeyNo()

Saludos,

Adhemar
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1599
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia

Re: Contar registros

Postby Carlos Mora » Tue Jul 19, 2011 9:18 am

Adhemar,

Te pego la pagina de OrdKeyCount(), es lo que buscas. Respeta scopes, no respeta filtros.

ORDKEYCOUNT()
Return the number of keys in an order
------------------------------------------------------------------------------
Syntax

ORDKEYCOUNT([<cOrder> | <nPosition>],
[<cIndexFile>]) --> nKeys

Arguments

<cOrder> | <nPosition> is the name of the order or a number
representing its position in the order list. Using the order name is
the preferred method since the position may be difficult to determine
using multiple-order index files. If omitted or NIL, the controlling
order is assumed.

Specifying an invalid order will raise a runtime error.

<cIndexFile> is the name of an index file, including an optional
drive and directory (no extension should be specified). Use this
argument with <cOrder> to remove ambiguity when there are two or more
orders with the same name in different index files.

If <cIndexFile> is not open by the current process, a runtime error is
raised.

Returns

ORDKEYCOUNT() returns the number of keys in the specified order.

Description

ORDKEYCOUNT() counts the keys in the specified order and returns the
result as a numeric value. If the order is not conditional and no scope
has been set for it, ORDKEYCOUNT() is identical to RECCOUNT(), returning
the number of records in the database file. However, for a conditional
order, there may be fewer keys than there are records, since some
records may not meet the order's for condition or may not fall inside
the scope specified by ORDSCOPE()--in counting the keys, ORDKEYCOUNT()
respects the currently defined scope and for condition.

By default, this function operates on the currently selected work area.
It will operate on an unselected work area if you specify it as part of
an aliased expression.

Examples

¦ This example demonstrates using ORDKEYCOUNT() with various
orders:

USE customer
// Assume 1000 total records,
// 500 less than thirty years old, and
// 895 making less than 50,000

INDEX ON Age TO Age

INDEX ON First TO First FOR Age < 30
INDEX ON Last TO Last FOR Salary < 50000

// Age is the controlling order
SET INDEX TO Age, First, Last

? RECCOUNT() // Result: 1000
? ORDKEYCOUNT() // Result: 1000

? ORDKEYCOUNT("First") // Result: 500
? ORDKEYCOUNT(3) // Result: 895

Files Library is CLIPPER.LIB.
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Carlos Mora
 
Posts: 988
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: Contar registros

Postby acuellar » Tue Jul 19, 2011 2:17 pm

Gracias Carlos,

Esa funcion buscaba.

Saludos,

Adhemar
Saludos,

Adhemar C.
User avatar
acuellar
 
Posts: 1599
Joined: Tue Oct 28, 2008 6:26 pm
Location: Santa Cruz-Bolivia


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 158 guests