i dont have much expiriance with SQL and i am trying to crack my head on this query. i have 3 tables: Projects, Calculator and partialBilling (note: the 'calculator' columns you see at the code ive added 'k','l','m' etc are real...i didnt gave them those names...).
the query is working fine but part of the values that i am expecting from the aggregate function ('sumofTotal' column) are returning as null values and and they should not be null. I would be grateful if someone point out the mistake in the query.
SELECT Projects.SpCall,Projects.CustName,Projects.CustNumber
,Projects.ReceiveDate,Projects.StartDate,Projects.ProjectType
,Calculator.AN,Projects.Professional,Projects.PmUserName
,Projects.AcountManager,Projects.CrmCallNum,Projects.ProjectCategory
,Projects.CallNum,Projects.ContactName,Projects.ContactPhone
,Projects.ContactEmail,Projects.HiddenNote,Projects.RowColor
, Projects.HeaderCellText,
SUM(Calculator.K + Calculator.L + Calculator.M + Calculator.N + Calculator.AD + Calculator.AR) AS sumofTotal
,partialBilling.Ammount FROM Projects LEFT JOIN Calculator ON Projects.SpCall=Calculator.AQ
LEFT JOIN partialBilling ON Projects.SpCall = partialBilling.spCall
WHERE PmUserName= 'JOHN DOE'AND OpertionalStatus
<> 'Billed' AND OpertionalStatus<> 'Finished' AND
OpertionalStatus<> 'Passed To Billing' AND OpertionalStatus<> 'Scanning'
AND OpertionalStatus<> 'Ended'
AND OpertionalStatus<> 'Green Billing'
AND (GeneralStatus= 'Passed To Project Manager'
OR GeneralStatus= 'Astrategic Project')
GROUP BY Projects.SpCall,Projects.CustName,Projects.CustNumber
,Projects.ReceiveDate,Projects.StartDate,Projects.ProjectType
,Calculator.AN,Projects.Professional,Projects.PmUserName
,Projects.AcountManager,Projects.CrmCallNum,Projects.ProjectCategory
,Projects.CallNum,Projects.ContactName,Projects.ContactPhone
,Projects.ContactEmail,Projects.HiddenNote,Projects.RowColor
, Projects.HeaderCellText,partialBilling.Ammount;