/*
 * 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.ViewApplicationsReceivedFromEpguRecord;


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>registration_change_address.view_applications_received_from_epgu</code>
     */
    public static final ViewApplicationsReceivedFromEpgu VIEW_APPLICATIONS_RECEIVED_FROM_EPGU = new ViewApplicationsReceivedFromEpgu();

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

    /**
     * The column
     * <code>registration_change_address.view_applications_received_from_epgu.applications_received_from_epgu_id</code>.
     */
    public final TableField<ViewApplicationsReceivedFromEpguRecord, Long> APPLICATIONS_RECEIVED_FROM_EPGU_ID = createField(DSL.name("applications_received_from_epgu_id"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>registration_change_address.view_applications_received_from_epgu.percent_executor_appointed</code>.
     */
    public final TableField<ViewApplicationsReceivedFromEpguRecord, BigDecimal> PERCENT_EXECUTOR_APPOINTED = createField(DSL.name("percent_executor_appointed"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>registration_change_address.view_applications_received_from_epgu.percent_executor_not_appointed_expired</code>.
     */
    public final TableField<ViewApplicationsReceivedFromEpguRecord, BigDecimal> PERCENT_EXECUTOR_NOT_APPOINTED_EXPIRED = createField(DSL.name("percent_executor_not_appointed_expired"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>registration_change_address.view_applications_received_from_epgu.percent_executor_not_appointed_on_time</code>.
     */
    public final TableField<ViewApplicationsReceivedFromEpguRecord, BigDecimal> PERCENT_EXECUTOR_NOT_APPOINTED_ON_TIME = createField(DSL.name("percent_executor_not_appointed_on_time"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>registration_change_address.view_applications_received_from_epgu.percent_registered</code>.
     */
    public final TableField<ViewApplicationsReceivedFromEpguRecord, BigDecimal> PERCENT_REGISTERED = createField(DSL.name("percent_registered"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>registration_change_address.view_applications_received_from_epgu.percent_registration_refusal</code>.
     */
    public final TableField<ViewApplicationsReceivedFromEpguRecord, BigDecimal> PERCENT_REGISTRATION_REFUSAL = createField(DSL.name("percent_registration_refusal"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>registration_change_address.view_applications_received_from_epgu.percent_refusal_provide_service</code>.
     */
    public final TableField<ViewApplicationsReceivedFromEpguRecord, BigDecimal> PERCENT_REFUSAL_PROVIDE_SERVICE = createField(DSL.name("percent_refusal_provide_service"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>registration_change_address.view_applications_received_from_epgu.percent_provided</code>.
     */
    public final TableField<ViewApplicationsReceivedFromEpguRecord, BigDecimal> PERCENT_PROVIDED = createField(DSL.name("percent_provided"), SQLDataType.NUMERIC, this, "");

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

    private ViewApplicationsReceivedFromEpgu(Name alias, Table<ViewApplicationsReceivedFromEpguRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_applications_received_from_epgu" as  SELECT applications_received_from_epgu.applications_received_from_epgu_id,
         COALESCE(round((((applications_received_from_epgu.count_executor_appointed)::numeric * (100)::numeric) / NULLIF((applications_received_from_epgu.count_all)::numeric, (0)::numeric))), (0)::numeric) AS percent_executor_appointed,
         COALESCE(round((((applications_received_from_epgu.count_executor_not_appointed_expired)::numeric * (100)::numeric) / NULLIF((applications_received_from_epgu.count_all)::numeric, (0)::numeric))), (0)::numeric) AS percent_executor_not_appointed_expired,
         COALESCE(round((((applications_received_from_epgu.count_executor_not_appointed_on_time)::numeric * (100)::numeric) / NULLIF((applications_received_from_epgu.count_all)::numeric, (0)::numeric))), (0)::numeric) AS percent_executor_not_appointed_on_time,
         COALESCE(round((((applications_received_from_epgu.count_registered)::numeric * (100)::numeric) / NULLIF((applications_received_from_epgu.count_all)::numeric, (0)::numeric))), (0)::numeric) AS percent_registered,
         COALESCE(round((((applications_received_from_epgu.count_registration_refusal)::numeric * (100)::numeric) / NULLIF((applications_received_from_epgu.count_all)::numeric, (0)::numeric))), (0)::numeric) AS percent_registration_refusal,
         COALESCE(round((((applications_received_from_epgu.count_refusal_provide_service)::numeric * (100)::numeric) / NULLIF((applications_received_from_epgu.count_all)::numeric, (0)::numeric))), (0)::numeric) AS percent_refusal_provide_service,
         COALESCE(round((((applications_received_from_epgu.count_provided)::numeric * (100)::numeric) / NULLIF((applications_received_from_epgu.count_all)::numeric, (0)::numeric))), (0)::numeric) AS percent_provided
        FROM registration_change_address.applications_received_from_epgu;
        """), where);
    }

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

    /**
     * Create an aliased
     * <code>registration_change_address.view_applications_received_from_epgu</code>
     * table reference
     */
    public ViewApplicationsReceivedFromEpgu(Name alias) {
        this(alias, VIEW_APPLICATIONS_RECEIVED_FROM_EPGU);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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