This paper describes the processing and transformation of medical data from a clinical database to a statistical data matrix. Precise extraction and linking tools must be available for the desired data to be processed for statistical purposes. We show that flexible mechanisms are required for the different types of users, such as physicians and statisticians. In our retrieval tools we use logical queries based on operands and operators. The paper describes the method and appliance of the operators with which the desired matrix is created through a process of selection and linking. Examples with a Kaplan-Meier function and time-dependent covariables demonstrate how our model is useful for different user groups.