I want to select maximum value from a table's column named quotationVersion from table quotation,
  getOneMaximumQuotationVersion() {
    const query = this.createQueryBuilder("quotation");
    query.select("MAX(quotation.quotationVersion)", "max");
    // query.addSelect("MAX(quotation.quotationVersion)", "max");
    return query.getOne();
  }
                If you want to add functions like MAX, SUM in the selection clause, you need to do getRawOne() or getRawMany(). This will give you the raw response:
getOneMaximumQuotationVersion() {
    const query = this.createQueryBuilder("quotation");
    query.select("MAX(quotation.quotationVersion)", "max");
    // query.addSelect("MAX(quotation.quotationVersion)", "max");
    return query.getRawOne();
  }
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With