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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>summonses_list.view_rf_leaving_ban</code>
     */
    public static final ViewRfLeavingBan VIEW_RF_LEAVING_BAN = new ViewRfLeavingBan();

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

    /**
     * The column
     * <code>summonses_list.view_rf_leaving_ban.rf_leaving_ban_id</code>.
     */
    public final TableField<ViewRfLeavingBanRecord, Long> RF_LEAVING_BAN_ID = createField(DSL.name("rf_leaving_ban_id"), SQLDataType.BIGINT, this, "");

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

    /**
     * The column
     * <code>summonses_list.view_rf_leaving_ban.percent_for_sign</code>.
     */
    public final TableField<ViewRfLeavingBanRecord, BigDecimal> PERCENT_FOR_SIGN = createField(DSL.name("percent_for_sign"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list.view_rf_leaving_ban.percent_signed</code>.
     */
    public final TableField<ViewRfLeavingBanRecord, BigDecimal> PERCENT_SIGNED = createField(DSL.name("percent_signed"), SQLDataType.NUMERIC, this, "");

    /**
     * The column <code>summonses_list.view_rf_leaving_ban.percent_enter</code>.
     */
    public final TableField<ViewRfLeavingBanRecord, BigDecimal> PERCENT_ENTER = createField(DSL.name("percent_enter"), SQLDataType.NUMERIC, this, "");

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

    private ViewRfLeavingBan(Name alias, Table<ViewRfLeavingBanRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_rf_leaving_ban" as  SELECT rf_leaving_ban.rf_leaving_ban_id,
         ((rf_leaving_ban.count_for_sign + rf_leaving_ban.count_signed) + rf_leaving_ban.count_enter) AS count_all,
         COALESCE(round((((rf_leaving_ban.count_for_sign)::numeric * (100)::numeric) / NULLIF((((rf_leaving_ban.count_for_sign + rf_leaving_ban.count_signed) + rf_leaving_ban.count_enter))::numeric, (0)::numeric))), (0)::numeric) AS percent_for_sign,
         COALESCE(round((((rf_leaving_ban.count_signed)::numeric * (100)::numeric) / NULLIF((((rf_leaving_ban.count_for_sign + rf_leaving_ban.count_signed) + rf_leaving_ban.count_enter))::numeric, (0)::numeric))), (0)::numeric) AS percent_signed,
         COALESCE(round((((rf_leaving_ban.count_enter)::numeric * (100)::numeric) / NULLIF((((rf_leaving_ban.count_for_sign + rf_leaving_ban.count_signed) + rf_leaving_ban.count_enter))::numeric, (0)::numeric))), (0)::numeric) AS percent_enter
        FROM summonses_list.rf_leaving_ban;
        """), where);
    }

    /**
     * Create an aliased <code>summonses_list.view_rf_leaving_ban</code> table
     * reference
     */
    public ViewRfLeavingBan(String alias) {
        this(DSL.name(alias), VIEW_RF_LEAVING_BAN);
    }

    /**
     * Create an aliased <code>summonses_list.view_rf_leaving_ban</code> table
     * reference
     */
    public ViewRfLeavingBan(Name alias) {
        this(alias, VIEW_RF_LEAVING_BAN);
    }

    /**
     * Create a <code>summonses_list.view_rf_leaving_ban</code> table reference
     */
    public ViewRfLeavingBan() {
        this(DSL.name("view_rf_leaving_ban"), null);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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