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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>deregistration.view_decisions_signing</code>
     */
    public static final ViewDecisionsSigning VIEW_DECISIONS_SIGNING = new ViewDecisionsSigning();

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

    /**
     * The column
     * <code>deregistration.view_decisions_signing.decisions_signing_id</code>.
     */
    public final TableField<ViewDecisionsSigningRecord, Long> DECISIONS_SIGNING_ID = createField(DSL.name("decisions_signing_id"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>deregistration.view_decisions_signing.count_arrived_all</code>.
     */
    public final TableField<ViewDecisionsSigningRecord, Long> COUNT_ARRIVED_ALL = createField(DSL.name("count_arrived_all"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>deregistration.view_decisions_signing.percent_arrived_death_reason</code>.
     */
    public final TableField<ViewDecisionsSigningRecord, BigDecimal> PERCENT_ARRIVED_DEATH_REASON = createField(DSL.name("percent_arrived_death_reason"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>deregistration.view_decisions_signing.percent_arrived_age_limit</code>.
     */
    public final TableField<ViewDecisionsSigningRecord, BigDecimal> PERCENT_ARRIVED_AGE_LIMIT = createField(DSL.name("percent_arrived_age_limit"), SQLDataType.NUMERIC, this, "");

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

    private ViewDecisionsSigning(Name alias, Table<ViewDecisionsSigningRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_decisions_signing" as  SELECT decisions_signing.decisions_signing_id,
         (decisions_signing.count_arrived_death_reason + decisions_signing.count_arrived_age_limit) AS count_arrived_all,
         COALESCE(round((((decisions_signing.count_arrived_death_reason)::numeric * (100)::numeric) / NULLIF(((decisions_signing.count_arrived_death_reason + decisions_signing.count_arrived_age_limit))::numeric, (0)::numeric))), (0)::numeric) AS percent_arrived_death_reason,
         COALESCE(round((((decisions_signing.count_arrived_age_limit)::numeric * (100)::numeric) / NULLIF(((decisions_signing.count_arrived_death_reason + decisions_signing.count_arrived_age_limit))::numeric, (0)::numeric))), (0)::numeric) AS percent_arrived_age_limit
        FROM deregistration.decisions_signing;
        """), where);
    }

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

    /**
     * Create an aliased <code>deregistration.view_decisions_signing</code>
     * table reference
     */
    public ViewDecisionsSigning(Name alias) {
        this(alias, VIEW_DECISIONS_SIGNING);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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