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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>deregistration.view_removal_registration</code>
     */
    public static final ViewRemovalRegistration VIEW_REMOVAL_REGISTRATION = new ViewRemovalRegistration();

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

    /**
     * The column
     * <code>deregistration.view_removal_registration.removal_registration_id</code>.
     */
    public final TableField<ViewRemovalRegistrationRecord, Long> REMOVAL_REGISTRATION_ID = createField(DSL.name("removal_registration_id"), SQLDataType.BIGINT, this, "");

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

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

    /**
     * The column
     * <code>deregistration.view_removal_registration.percent_reason_death</code>.
     */
    public final TableField<ViewRemovalRegistrationRecord, BigDecimal> PERCENT_REASON_DEATH = createField(DSL.name("percent_reason_death"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>deregistration.view_removal_registration.percent_loss_citizenship</code>.
     */
    public final TableField<ViewRemovalRegistrationRecord, BigDecimal> PERCENT_LOSS_CITIZENSHIP = createField(DSL.name("percent_loss_citizenship"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>deregistration.view_removal_registration.percent_cancellation_record</code>.
     */
    public final TableField<ViewRemovalRegistrationRecord, BigDecimal> PERCENT_CANCELLATION_RECORD = createField(DSL.name("percent_cancellation_record"), SQLDataType.NUMERIC, this, "");

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

    private ViewRemovalRegistration(Name alias, Table<ViewRemovalRegistrationRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_removal_registration" as  SELECT removal_registration.removal_registration_id,
         (((removal_registration.count_age_limit + removal_registration.count_reason_death) + removal_registration.count_loss_citizenship) + removal_registration.count_cancellation_record) AS count_all,
         COALESCE(round((((removal_registration.count_age_limit)::numeric * (100)::numeric) / NULLIF(((((removal_registration.count_age_limit + removal_registration.count_reason_death) + removal_registration.count_loss_citizenship) + removal_registration.count_cancellation_record))::numeric, (0)::numeric))), (0)::numeric) AS percent_age_limit,
         COALESCE(round((((removal_registration.count_reason_death)::numeric * (100)::numeric) / NULLIF(((((removal_registration.count_age_limit + removal_registration.count_reason_death) + removal_registration.count_loss_citizenship) + removal_registration.count_cancellation_record))::numeric, (0)::numeric))), (0)::numeric) AS percent_reason_death,
         COALESCE(round((((removal_registration.count_loss_citizenship)::numeric * (100)::numeric) / NULLIF(((((removal_registration.count_age_limit + removal_registration.count_reason_death) + removal_registration.count_loss_citizenship) + removal_registration.count_cancellation_record))::numeric, (0)::numeric))), (0)::numeric) AS percent_loss_citizenship,
         COALESCE(round((((removal_registration.count_cancellation_record)::numeric * (100)::numeric) / NULLIF(((((removal_registration.count_age_limit + removal_registration.count_reason_death) + removal_registration.count_loss_citizenship) + removal_registration.count_cancellation_record))::numeric, (0)::numeric))), (0)::numeric) AS percent_cancellation_record
        FROM deregistration.removal_registration;
        """), where);
    }

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

    /**
     * Create an aliased <code>deregistration.view_removal_registration</code>
     * table reference
     */
    public ViewRemovalRegistration(Name alias) {
        this(alias, VIEW_REMOVAL_REGISTRATION);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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