/*
 * This file is generated by jOOQ.
 */
package ru.micord.webbpm.ervu.business_metrics.db_beans.deregistration.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.deregistration.Deregistration;
import ru.micord.webbpm.ervu.business_metrics.db_beans.deregistration.tables.records.ViewApplicationsSentFromEpguRecord;


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>deregistration.view_applications_sent_from_epgu</code>
     */
    public static final ViewApplicationsSentFromEpgu VIEW_APPLICATIONS_SENT_FROM_EPGU = new ViewApplicationsSentFromEpgu();

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

    /**
     * The column
     * <code>deregistration.view_applications_sent_from_epgu.applications_sent_from_epgu_id</code>.
     */
    public final TableField<ViewApplicationsSentFromEpguRecord, Long> APPLICATIONS_SENT_FROM_EPGU_ID = createField(DSL.name("applications_sent_from_epgu_id"), SQLDataType.BIGINT, this, "");

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

    /**
     * The column
     * <code>deregistration.view_applications_sent_from_epgu.percent_moved_residence</code>.
     */
    public final TableField<ViewApplicationsSentFromEpguRecord, BigDecimal> PERCENT_MOVED_RESIDENCE = createField(DSL.name("percent_moved_residence"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>deregistration.view_applications_sent_from_epgu.percent_departure_more_6_month</code>.
     */
    public final TableField<ViewApplicationsSentFromEpguRecord, BigDecimal> PERCENT_DEPARTURE_MORE_6_MONTH = createField(DSL.name("percent_departure_more_6_month"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>deregistration.view_applications_sent_from_epgu.percent_health_condition</code>.
     */
    public final TableField<ViewApplicationsSentFromEpguRecord, BigDecimal> PERCENT_HEALTH_CONDITION = createField(DSL.name("percent_health_condition"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>deregistration.view_applications_sent_from_epgu.percent_age_limit</code>.
     */
    public final TableField<ViewApplicationsSentFromEpguRecord, BigDecimal> PERCENT_AGE_LIMIT = createField(DSL.name("percent_age_limit"), SQLDataType.NUMERIC, this, "");

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

    private ViewApplicationsSentFromEpgu(Name alias, Table<ViewApplicationsSentFromEpguRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_applications_sent_from_epgu" as  SELECT applications_sent_from_epgu.applications_sent_from_epgu_id,
         (((applications_sent_from_epgu.count_moved_residence + applications_sent_from_epgu.count_departure_more_6_month) + applications_sent_from_epgu.count_health_condition) + applications_sent_from_epgu.count_age_limit) AS count_all,
         COALESCE(round((((applications_sent_from_epgu.count_moved_residence)::numeric * (100)::numeric) / NULLIF(((((applications_sent_from_epgu.count_moved_residence + applications_sent_from_epgu.count_departure_more_6_month) + applications_sent_from_epgu.count_health_condition) + applications_sent_from_epgu.count_age_limit))::numeric, (0)::numeric))), (0)::numeric) AS percent_moved_residence,
         COALESCE(round((((applications_sent_from_epgu.count_departure_more_6_month)::numeric * (100)::numeric) / NULLIF(((((applications_sent_from_epgu.count_moved_residence + applications_sent_from_epgu.count_departure_more_6_month) + applications_sent_from_epgu.count_health_condition) + applications_sent_from_epgu.count_age_limit))::numeric, (0)::numeric))), (0)::numeric) AS percent_departure_more_6_month,
         COALESCE(round((((applications_sent_from_epgu.count_health_condition)::numeric * (100)::numeric) / NULLIF(((((applications_sent_from_epgu.count_moved_residence + applications_sent_from_epgu.count_departure_more_6_month) + applications_sent_from_epgu.count_health_condition) + applications_sent_from_epgu.count_age_limit))::numeric, (0)::numeric))), (0)::numeric) AS percent_health_condition,
         COALESCE(round((((applications_sent_from_epgu.count_age_limit)::numeric * (100)::numeric) / NULLIF(((((applications_sent_from_epgu.count_moved_residence + applications_sent_from_epgu.count_departure_more_6_month) + applications_sent_from_epgu.count_health_condition) + applications_sent_from_epgu.count_age_limit))::numeric, (0)::numeric))), (0)::numeric) AS percent_age_limit
        FROM deregistration.applications_sent_from_epgu;
        """), where);
    }

    /**
     * Create an aliased
     * <code>deregistration.view_applications_sent_from_epgu</code> table
     * reference
     */
    public ViewApplicationsSentFromEpgu(String alias) {
        this(DSL.name(alias), VIEW_APPLICATIONS_SENT_FROM_EPGU);
    }

    /**
     * Create an aliased
     * <code>deregistration.view_applications_sent_from_epgu</code> table
     * reference
     */
    public ViewApplicationsSentFromEpgu(Name alias) {
        this(alias, VIEW_APPLICATIONS_SENT_FROM_EPGU);
    }

    /**
     * Create a <code>deregistration.view_applications_sent_from_epgu</code>
     * table reference
     */
    public ViewApplicationsSentFromEpgu() {
        this(DSL.name("view_applications_sent_from_epgu"), null);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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