Hi João,
You select is invalid even in VFP8 because it includes fiedls that are neither in GROUP BY clause nor are aggregate functions. What records values for thouse fields do you expect to come from? You can first get sum per matirial and than use it as derived table in join to whatever table you need.
SELECT b.material, SUM(b.Quantidade) as QUANT;
FROM FICCARC a ;
LEFT OUTER JOIN FICCARL b ;
ON a.encomenda = b.encomenda ;
LEFT OUTER JOIN FICMOLDE c ;
ON a.terceiro = val(c.molde) ;
WHERE a.encomenda=VAL(thisform.ncarga) ;
GROUP BY b.Material ;
>Hi all ,
>
>How can i convert this SQL statement to work with SQL Server,
>
>
>SELECT * , SUM(b.Quantidade) as QUANT;
> FROM FICCARC a ;
> LEFT OUTER JOIN FICCARL b ;
> ON a.encomenda = b.encomenda ;
> LEFT OUTER JOIN FICMOLDE c ;
> ON a.terceiro = val(c.molde) ;
> WHERE a.encomenda=VAL(thisform.ncarga) ;
> GROUP BY b.Material ;
>
>
>Error:
>is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
>If a put in the select one date field and in group the same field the sum is done by DATE and not by all records.
>
>
--sb--