• Having reformated the query at the bottom of the code you submited

    select distinct

    customer.*

    ,CustomerColor.Color

    ,CustomerColor.CustomerSubject

    ,b.AkharinKeraye

    ,b.Karkard

    ,b.Lcall

    from customer

    left outer join CustomerColor on Customer.CustomerColorID=CustomerColor.CustomerColorID

    ,(select [Service].CustomerID

    ,max([Service].SabtDate) as Lcall

    ,SUM(Service.Gheymat) as Karkard

    ,(select s.Gheymat

    from [Service] as s

    where s.SabtDate=max([Service].SabtDate)) as AkharinKeraye

    from [Service]

    group by [Service].CustomerID ) b

    order by Customer.CustomerID,Customer.FullName

    as far as im aware the Sub select after the left join is invalid syntax.

    You will need to do a join I would suggest something like this as a starting point

    select distinct

    customer.*

    ,CustomerColor.Color

    ,CustomerColor.CustomerSubject

    ,b.AkharinKeraye

    ,b.Karkard

    ,b.Lcall

    from customer

    left outer join CustomerColor on Customer.CustomerColorID=CustomerColor.CustomerColorID,

    INNER JOIN (select [Service].CustomerID

    ,max([Service].SabtDate) as Lcall

    ,SUM(Service.Gheymat) as Karkard

    ,(select s.Gheymat

    from [Service] as s

    where s.SabtDate=max([Service].SabtDate)) as AkharinKeraye

    from [Service]

    group by [Service].CustomerID) b on b.CustomerID=customer.customerId

    order by Customer.CustomerID,Customer.FullName

    though you still have a possible issue with the AkharinKeraye correlated sub query which could return more than one row.

    I'm not sure about the JOIN i added it might need to be a LEFT OUTER.

    _________________________________________________________________________
    SSC Guide to Posting and Best Practices