Hi friendsI have written an sql as following.but It has Error.where is my problem? @DocNum1 nvarchar(50), @DocNum2 nvarchar(50), @DocDate1 nvarchar(13), @DocDate2 nvarchar(13), @MoeCode1 nvarchar(6), @MoeCode2 nvarchar(6), @Office intASselect DocNum,DocDate,DocDetails,Debtor,Creditor,abs((Sum(Debtor)- Sum(Creditor))) as 'remain',Document.FacNum,Document.Date,[Value/Count],UnitPrice from Document where (MoeCode between @MoeCode1 and @MoeCode2) and (DocNum between @DocNum1 and @DocNum2) and (DocDate between @DocDate1 and @DocDate2) and OfficeID=@Office
the Error is:Column "Document.DocNum" is invalid in the select list because it is not contained in either an aggrigate function or the Group By clause.thx for your attentionSara Dajer