Subject Re: [IBO] Re: Error in calculations SQL
Author Helen Borrie
At 06:40 PM 17/01/2007, you wrote:
>When I execute select:
>
>SELECT sum(coalesce(Precio, 0) * coalesce(Cantidad, 1) *
>(100-coalesce(Descuento, 0))/100)*1.16 as TotalAlbaran
>FROM LinAlbaranes
>WHERE AnoAlbaran=2007 and SerieAlbaran=0 and idAlbaran=36
>
>it gives back the error to me "Invalid KeyLinks entry:
>LINALBARANES.ANOALBARAN"

Of course it is invalid. It is not in the output set.

Either clear the KeyLinks entirely and set AutoDefineKeylinks false,
or use this:

SELECT
AnoAlbaran,
SerieAlbaran,
idAlbaran,
sum(coalesce(Precio, 0) * coalesce(Cantidad, 1) *
(100-coalesce(Descuento, 0))/100)*1.16 as TotalAlbaran
FROM LinAlbaranes
WHERE AnoAlbaran=2007 and SerieAlbaran=0 and idAlbaran=36
group by 1, 2, 3


and set Keylinks to
AnoAlbaran
SerieAlbaran
idAlbaran

Helen