Форум » [x]Harbour » Подскажите команду которая суммирует числовые поля? » Ответить

Подскажите команду которая суммирует числовые поля?

Eduard: Надо функцию что-то типа как сумм() в Ексель что-бы просуммировать числовое поле по заданным параметрам. допустим, есть база с тремя полями - индекс, дата выплаты, сумма выплаты - необходимо по индексу и дате выплаты просуммировать данные в диапазоне индекса и даты выплаты.

Ответов - 4

Dima: dbeval

Andrey: SUM Calculates the sum of numeric expressions in the current work area. Syntax [pre2] SUM <expressions,...> ; TO <resultVarNames,...> ; [<Scope>] ; [WHILE <lWhileCondition>] ; [FOR <lForCondition>][/pre2] Arguments <expressions,...> This is a comma separated list of numeric expressions that are evaluated for the records of the current work area. TO <resultVarNames,...> A comma separated list of variable names that are assigned the results of the calculation. The number of <resultVarNames,...> must match exactly the number of <expressions,...>. <Scope> This option defines the number of records to sum. It defaults to ALL. The NEXT <nCount> sums the next <nCount> records, while the REST scope sums records beginning with the current record down to the end of file. WHILE <lWhileCondition> This is a logical expression indicating to continue calculation while the condition is true. The SUM operation stops as soon as <lWhileCondition> yields .F. (false). FOR <lForCondition> This is a logical expression which is evaluated for all records in the current work area. Those records where <lForCondition> yields .T. (true) are included in the calculation. Description The SUM command is used to calculate sum values for one or more numeric expressions. The expressions are evaluated in the current work area. The number of records to include in the calculation can be restricted using a FOR and/or WHILE condition or by explicitly defining a scope. Records marked for deletion are not included in the calculation when SET DELETED is set to ON. Info See also: AVERAGE, DbEval(), TOTAL Category: Database commands Source: rdd\dbcmd.c LIB: xhb.lib DLL: xhbdll.dll [pre2]Example // The example adds daily sales for the month of December. PROCEDURE Main LOCAL nSales := 0 USE Invoice SUM FIELD->Total TO nSales FOR ; Month(PayDate) == 12 .AND. Year(PayDate)=Year(Date()) ? "December sales:", nSales CLOSE Invoice RETURN[/pre2] -------------------------------------------------------------------------------- Copyright © 2006-2007 xHarbour.com Inc. All rights reserved

Dima: Andrey пишет: SUM Ну если глянуть Std.ch то все равно увидим что живет там Dbeval


LYSK: А не об этом ли? А именно аналог SQL SELECT data,ind,SUM(summa) from baza group by data,ind И нужна команда не SUM а TOTAL Summarize records by key value to a database (.dbf) file Previous Top Next -------------------------------------------------------------------------------- SYNTAX TOTAL ON <expKey> [ FIELDS <idField list>] TO <xcDatabase>[<scope>] [ WHILE <lCondition>] [ FOR <lCondition>]



полная версия страницы