Despite of Standard Deviation is one of most relevant parameter of descriptive statistics, it isn't available as common aggregation function for some SQL server. Here is described how to calculate and use standard deviation in a single select query. Finally a better and numerically stable sql procedure is shown.
This document shown two different way for server side managment of Data Tree with Firebird. First method uses Recursive Common Table Expression. Second method uses Recursive Stored Procedure
As you know, Firebird doesn’t have Autoinc fields but you can use triggers and sequences (generators) in order to obtain Autoinc features. On the web you can find many example about this.
Unfortunately I can’t find examples where triggered field (autoinc field) could receive a NOT NULL value, as is in data import from script. Following common examples, when the triggered field receives a value, the generator isn’t incremented so you may have “key violation” on future inserts.
In this document is shown a safe trigger example that can be used also when the triggered filed could receive a value.