SELECT 
    mt.*, checkOutCount, itemType
FROM
    spl3.x_checkOutCountBib x,
    spl3._rawXmlDataCheckIns raw,
    spl3.transactions mt
        INNER JOIN
    (SELECT 
        bibNumber,
            MIN(checkOut) minCheckOut,
            MAX(checkOut) maxCheckOut
    FROM
        spl3.transactions t
    GROUP BY bibNumber) t ON mt.bibNumber = t.bibNumber
        AND mt.checkOut = t.minCheckOut
        AND mt.maxCheckOut = t.maxCheckOut
        and mt.bibNumber = x.bibNumber