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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>deregistration.view_data_from_gir_vu</code>
     */
    public static final ViewDataFromGirVu VIEW_DATA_FROM_GIR_VU = new ViewDataFromGirVu();

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

    /**
     * The column
     * <code>deregistration.view_data_from_gir_vu.data_from_gir_vu_id</code>.
     */
    public final TableField<ViewDataFromGirVuRecord, Long> DATA_FROM_GIR_VU_ID = createField(DSL.name("data_from_gir_vu_id"), SQLDataType.BIGINT, this, "");

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

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

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

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

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

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

    /**
     * Create an aliased <code>deregistration.view_data_from_gir_vu</code> table
     * reference
     */
    public ViewDataFromGirVu(Name alias) {
        this(alias, VIEW_DATA_FROM_GIR_VU);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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