query x++ without value returned from table in join


I try to create a query with a “group by” statement and a “join”.

This is the query:

select sum(TaxBaseAmountCur)
from _A
index hint AnnoCodiceAnagTT_Idx
group by Anno, CodiceAnag, TipoDato, NC,
AccountNum, InvoiceId, InvoiceDate, CountryRegionId,
where _A.Test != NoYes::Yes &&
_A.Anno == iAnno &&
_A.CountryRegionId != ‘IT’ &&
_A.AccountNum == ‘22225375’ &&
_A.TipoDato == WebUserType::Vendor
join _B
index hint TaxCodeIdx
where _B.TaxCode == _A.TaxCode;

The problem is that I can’t see the value of _B.TaxCode or other fields of table _B.

If I delete the “group by” statement I haven’t any problems.

Could someone help me to understand why?

Thanks a lot!

If you use group by, only fields used for grouping or aggregated fields have defined values. You don’t group by nor aggregate any field from _B, therefore you don’t get any value from _B.

Now it works!

Thanks a lot for your replay!!!