• Without knowing the structure of all your tables and data its difficult to help, this may point you in the right direction (untested as no consumable data):

    SELECT

    Qry.platenr

    , 'invoicefm' AS Company

    , Qry.ClientId

    , Qry.Name

    , Qry.Invoice_id AS Document_Nr

    , Qry.Invoice_Date

    , Qry.Paid, Qry AS AllValues

    FROM

    (

    SELECT

    *

    ,ROW_NUMBER() OVER (PARTITION BY Invoice_FM .DOCUMENT_NR ORDER BY vehicle .Platenr) AS RowNum

    FROM

    Invoice_FM

    INNER JOIN Client

    ON Invoice_FM.ClientId = Client.ClientID

    LEFT JOIN vehicle

    ON Invoice_FM.Invoice_id = vehicle.Invoice_Nr

    WHERE Invoice_FM.deleted = 0

    AND client.type_client = 'Fleet'

    ) AS Qry

    WHERE

    Qry.RowNum = 1

    ORDER BY Document_Nr

    Andy

    ==========================================================================================================================
    A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila. Mitch Ratcliffe