Код: Выделить всё
FDQuery1->SQL->Text = "SELECT SQRT_SUM(FIELD_1) FROM TABLE_1 WHERE ID = 1";
FDQuery1->Open();
ShowMessage(Form1->FDQuery1->Fields->Fields[0]->AsFloat);
FDQuery1->Close();
Код: Выделить всё
void __fastcall TForm1::FDSQLiteFunction1Calculate(TSQLiteFunctionInstance *AFunc,
TSQLiteInputs *AInputs, TSQLiteOutput *AOutput, TObject *&AUserData)
{
double sum = 0;
for (long i = 0; i < AInputs->Count; i++) sum += AInputs->Inputs[i]->AsFloat;
AOutput->AsFloat = sqrt(sum);
}
FDSQLiteFunction1->DriverLink = FDPhysSQLiteDriverLink1;
FDSQLiteFunction1->FunctionName = 'SQRT_SUM';
FDSQLiteFunction1->Aggregated = true;
FDSQLiteFunction1->ArgumentsCount = 1;
FDSQLiteFunction1->OnCalculate = FDSQLiteFunction1Calculate;
FDSQLiteFunction1->Active = true;
Подробнее здесь: https://stackoverflow.com/questions/791 ... tefunction
Мобильная версия