/*
 * This file is generated by jOOQ.
 */
package ru.micord.webbpm.ervu.business_metrics.db_beans.registration_change_address.tables;


import java.math.BigDecimal;
import java.util.Collection;

import org.jooq.Condition;
import org.jooq.Field;
import org.jooq.Name;
import org.jooq.PlainSQL;
import org.jooq.QueryPart;
import org.jooq.SQL;
import org.jooq.Schema;
import org.jooq.Select;
import org.jooq.Stringly;
import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.TableOptions;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.jooq.impl.TableImpl;

import ru.micord.webbpm.ervu.business_metrics.db_beans.registration_change_address.RegistrationChangeAddress;
import ru.micord.webbpm.ervu.business_metrics.db_beans.registration_change_address.tables.records.ViewPersonalInfoStatRecord;


/**
 * This class is generated by jOOQ.
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class ViewPersonalInfoStat extends TableImpl<ViewPersonalInfoStatRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>registration_change_address.view_personal_info_stat</code>
     */
    public static final ViewPersonalInfoStat VIEW_PERSONAL_INFO_STAT = new ViewPersonalInfoStat();

    /**
     * The class holding records for this type
     */
    @Override
    public Class<ViewPersonalInfoStatRecord> getRecordType() {
        return ViewPersonalInfoStatRecord.class;
    }

    /**
     * The column
     * <code>registration_change_address.view_personal_info_stat.personal_info_stat_id</code>.
     */
    public final TableField<ViewPersonalInfoStatRecord, Long> PERSONAL_INFO_STAT_ID = createField(DSL.name("personal_info_stat_id"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>registration_change_address.view_personal_info_stat.count_all</code>.
     */
    public final TableField<ViewPersonalInfoStatRecord, Long> COUNT_ALL = createField(DSL.name("count_all"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>registration_change_address.view_personal_info_stat.percent_refused</code>.
     */
    public final TableField<ViewPersonalInfoStatRecord, BigDecimal> PERCENT_REFUSED = createField(DSL.name("percent_refused"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>registration_change_address.view_personal_info_stat.percent_unloaded</code>.
     */
    public final TableField<ViewPersonalInfoStatRecord, BigDecimal> PERCENT_UNLOADED = createField(DSL.name("percent_unloaded"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>registration_change_address.view_personal_info_stat.percent_accepted_to_send</code>.
     */
    public final TableField<ViewPersonalInfoStatRecord, BigDecimal> PERCENT_ACCEPTED_TO_SEND = createField(DSL.name("percent_accepted_to_send"), SQLDataType.NUMERIC, this, "");

    private ViewPersonalInfoStat(Name alias, Table<ViewPersonalInfoStatRecord> aliased) {
        this(alias, aliased, (Field<?>[]) null, null);
    }

    private ViewPersonalInfoStat(Name alias, Table<ViewPersonalInfoStatRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_personal_info_stat" as  SELECT personal_info_stat.personal_info_stat_id,
         ((personal_info_stat.count_refused + personal_info_stat.count_accepted_to_send) + personal_info_stat.count_unloaded) AS count_all,
         COALESCE(round((((personal_info_stat.count_refused)::numeric * (100)::numeric) / NULLIF((((personal_info_stat.count_refused + personal_info_stat.count_accepted_to_send) + personal_info_stat.count_unloaded))::numeric, (0)::numeric))), (0)::numeric) AS percent_refused,
         COALESCE(round((((personal_info_stat.count_unloaded)::numeric * (100)::numeric) / NULLIF((((personal_info_stat.count_refused + personal_info_stat.count_accepted_to_send) + personal_info_stat.count_unloaded))::numeric, (0)::numeric))), (0)::numeric) AS percent_unloaded,
         COALESCE(round((((personal_info_stat.count_accepted_to_send)::numeric * (100)::numeric) / NULLIF((((personal_info_stat.count_refused + personal_info_stat.count_accepted_to_send) + personal_info_stat.count_unloaded))::numeric, (0)::numeric))), (0)::numeric) AS percent_accepted_to_send
        FROM registration_change_address.personal_info_stat;
        """), where);
    }

    /**
     * Create an aliased
     * <code>registration_change_address.view_personal_info_stat</code> table
     * reference
     */
    public ViewPersonalInfoStat(String alias) {
        this(DSL.name(alias), VIEW_PERSONAL_INFO_STAT);
    }

    /**
     * Create an aliased
     * <code>registration_change_address.view_personal_info_stat</code> table
     * reference
     */
    public ViewPersonalInfoStat(Name alias) {
        this(alias, VIEW_PERSONAL_INFO_STAT);
    }

    /**
     * Create a <code>registration_change_address.view_personal_info_stat</code>
     * table reference
     */
    public ViewPersonalInfoStat() {
        this(DSL.name("view_personal_info_stat"), null);
    }

    @Override
    public Schema getSchema() {
        return aliased() ? null : RegistrationChangeAddress.REGISTRATION_CHANGE_ADDRESS;
    }

    @Override
    public ViewPersonalInfoStat as(String alias) {
        return new ViewPersonalInfoStat(DSL.name(alias), this);
    }

    @Override
    public ViewPersonalInfoStat as(Name alias) {
        return new ViewPersonalInfoStat(alias, this);
    }

    @Override
    public ViewPersonalInfoStat as(Table<?> alias) {
        return new ViewPersonalInfoStat(alias.getQualifiedName(), this);
    }

    /**
     * Rename this table
     */
    @Override
    public ViewPersonalInfoStat rename(String name) {
        return new ViewPersonalInfoStat(DSL.name(name), null);
    }

    /**
     * Rename this table
     */
    @Override
    public ViewPersonalInfoStat rename(Name name) {
        return new ViewPersonalInfoStat(name, null);
    }

    /**
     * Rename this table
     */
    @Override
    public ViewPersonalInfoStat rename(Table<?> name) {
        return new ViewPersonalInfoStat(name.getQualifiedName(), null);
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewPersonalInfoStat where(Condition condition) {
        return new ViewPersonalInfoStat(getQualifiedName(), aliased() ? this : null, null, condition);
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewPersonalInfoStat where(Collection<? extends Condition> conditions) {
        return where(DSL.and(conditions));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewPersonalInfoStat where(Condition... conditions) {
        return where(DSL.and(conditions));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewPersonalInfoStat where(Field<Boolean> condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ViewPersonalInfoStat where(SQL condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ViewPersonalInfoStat where(@Stringly.SQL String condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ViewPersonalInfoStat where(@Stringly.SQL String condition, Object... binds) {
        return where(DSL.condition(condition, binds));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ViewPersonalInfoStat where(@Stringly.SQL String condition, QueryPart... parts) {
        return where(DSL.condition(condition, parts));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewPersonalInfoStat whereExists(Select<?> select) {
        return where(DSL.exists(select));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ViewPersonalInfoStat whereNotExists(Select<?> select) {
        return where(DSL.notExists(select));
    }
}
