I've a set of models like the one that I've already explained in https://issues.jboss.org/browse/TEIID-1562. In addition I've a physical model, named sole_rugiada_phy, which extracts data from a SQL Server 2005 database. On top of it there's a view model, named sole_rugiada_log, which transform some fields and does some joins grouping.
In particular the base table named 'vendita_referenza' is defined as follows:
If I run the following query, that is a simple SELECT statement, everything works fine:
The query above retrieves 18717 records. But if I remove some fields from the SELECT statements something goes wrong. Take for example the following query:
The above query gets only one record, which is a grouping over all the record, even if it doesn't include a GROUP BY clause. It's not clear what type of aggregation it does. It seems to be a sum of all records, but the result is not totally exact. The value of 'fatturato' is near the real sum (5043502.561000000 instead of 5046687.249000000), but the value of 'quantita' is much different from the real sum (489566 instead of 5537638).
I noticed that removing the GROUP BY from the definition of the base table the problem disappears, but, of course, most of times this cannot be used as a workaround.
Attached there are the project of the VDB and a log of the execution of the query that produces the wrong result.