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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>summonses_list_subsystem.view_summonses_list</code>
     */
    public static final ViewSummonsesList VIEW_SUMMONSES_LIST = new ViewSummonsesList();

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

    /**
     * The column
     * <code>summonses_list_subsystem.view_summonses_list.summonses_list_id</code>.
     */
    public final TableField<ViewSummonsesListRecord, Long> SUMMONSES_LIST_ID = createField(DSL.name("summonses_list_id"), SQLDataType.BIGINT, this, "");

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

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

    /**
     * The column
     * <code>summonses_list_subsystem.view_summonses_list.percent_arrived_all</code>.
     */
    public final TableField<ViewSummonsesListRecord, BigDecimal> PERCENT_ARRIVED_ALL = createField(DSL.name("percent_arrived_all"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list_subsystem.view_summonses_list.percent_view_arrived</code>.
     */
    public final TableField<ViewSummonsesListRecord, BigDecimal> PERCENT_VIEW_ARRIVED = createField(DSL.name("percent_view_arrived"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list_subsystem.view_summonses_list.percent_not_view_arrived</code>.
     */
    public final TableField<ViewSummonsesListRecord, BigDecimal> PERCENT_NOT_VIEW_ARRIVED = createField(DSL.name("percent_not_view_arrived"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list_subsystem.view_summonses_list.count_less_20_days_all</code>.
     */
    public final TableField<ViewSummonsesListRecord, Long> COUNT_LESS_20_DAYS_ALL = createField(DSL.name("count_less_20_days_all"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>summonses_list_subsystem.view_summonses_list.percent_less_20_days_all</code>.
     */
    public final TableField<ViewSummonsesListRecord, BigDecimal> PERCENT_LESS_20_DAYS_ALL = createField(DSL.name("percent_less_20_days_all"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list_subsystem.view_summonses_list.percent_view_less_20_days</code>.
     */
    public final TableField<ViewSummonsesListRecord, BigDecimal> PERCENT_VIEW_LESS_20_DAYS = createField(DSL.name("percent_view_less_20_days"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list_subsystem.view_summonses_list.percent_not_view_less_20_days</code>.
     */
    public final TableField<ViewSummonsesListRecord, BigDecimal> PERCENT_NOT_VIEW_LESS_20_DAYS = createField(DSL.name("percent_not_view_less_20_days"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list_subsystem.view_summonses_list.count_greater_20_days_all</code>.
     */
    public final TableField<ViewSummonsesListRecord, Long> COUNT_GREATER_20_DAYS_ALL = createField(DSL.name("count_greater_20_days_all"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>summonses_list_subsystem.view_summonses_list.percent_greater_20_days_all</code>.
     */
    public final TableField<ViewSummonsesListRecord, BigDecimal> PERCENT_GREATER_20_DAYS_ALL = createField(DSL.name("percent_greater_20_days_all"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list_subsystem.view_summonses_list.percent_view_greater_20_days</code>.
     */
    public final TableField<ViewSummonsesListRecord, BigDecimal> PERCENT_VIEW_GREATER_20_DAYS = createField(DSL.name("percent_view_greater_20_days"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list_subsystem.view_summonses_list.percent_not_view_greater_20_days</code>.
     */
    public final TableField<ViewSummonsesListRecord, BigDecimal> PERCENT_NOT_VIEW_GREATER_20_DAYS = createField(DSL.name("percent_not_view_greater_20_days"), SQLDataType.NUMERIC, this, "");

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

    private ViewSummonsesList(Name alias, Table<ViewSummonsesListRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_summonses_list" as  SELECT summonses_list.summonses_list_id,
         (((((summonses_list.count_view_arrived + summonses_list.count_not_view_arrived) + summonses_list.count_view_less_20_days) + summonses_list.count_not_view_less_20_days) + summonses_list.count_view_greater_20_days) + summonses_list.count_not_view_greater_20_days) AS count_all,
         (summonses_list.count_view_arrived + summonses_list.count_not_view_arrived) AS count_arrived_all,
         COALESCE(round(((((summonses_list.count_view_arrived + summonses_list.count_not_view_arrived))::numeric * (100)::numeric) / NULLIF(((((((summonses_list.count_view_arrived + summonses_list.count_not_view_arrived) + summonses_list.count_view_less_20_days) + summonses_list.count_not_view_less_20_days) + summonses_list.count_view_greater_20_days) + summonses_list.count_not_view_greater_20_days))::numeric, (0)::numeric))), (0)::numeric) AS percent_arrived_all,
         COALESCE(round((((summonses_list.count_view_arrived)::numeric * (100)::numeric) / NULLIF(((summonses_list.count_view_arrived + summonses_list.count_not_view_arrived))::numeric, (0)::numeric))), (0)::numeric) AS percent_view_arrived,
         COALESCE(round((((summonses_list.count_not_view_arrived)::numeric * (100)::numeric) / NULLIF(((summonses_list.count_view_arrived + summonses_list.count_not_view_arrived))::numeric, (0)::numeric))), (0)::numeric) AS percent_not_view_arrived,
         (summonses_list.count_view_less_20_days + summonses_list.count_not_view_less_20_days) AS count_less_20_days_all,
         COALESCE(round(((((summonses_list.count_view_less_20_days + summonses_list.count_not_view_less_20_days))::numeric * (100)::numeric) / NULLIF(((((((summonses_list.count_view_arrived + summonses_list.count_not_view_arrived) + summonses_list.count_view_less_20_days) + summonses_list.count_not_view_less_20_days) + summonses_list.count_view_greater_20_days) + summonses_list.count_not_view_greater_20_days))::numeric, (0)::numeric))), (0)::numeric) AS percent_less_20_days_all,
         COALESCE(round((((summonses_list.count_view_less_20_days)::numeric * (100)::numeric) / NULLIF(((summonses_list.count_view_less_20_days + summonses_list.count_not_view_less_20_days))::numeric, (0)::numeric))), (0)::numeric) AS percent_view_less_20_days,
         COALESCE(round((((summonses_list.count_not_view_less_20_days)::numeric * (100)::numeric) / NULLIF(((summonses_list.count_view_less_20_days + summonses_list.count_not_view_less_20_days))::numeric, (0)::numeric))), (0)::numeric) AS percent_not_view_less_20_days,
         (summonses_list.count_view_greater_20_days + summonses_list.count_not_view_greater_20_days) AS count_greater_20_days_all,
         COALESCE(round(((((summonses_list.count_view_greater_20_days + summonses_list.count_not_view_greater_20_days))::numeric * (100)::numeric) / NULLIF(((((((summonses_list.count_view_arrived + summonses_list.count_not_view_arrived) + summonses_list.count_view_less_20_days) + summonses_list.count_not_view_less_20_days) + summonses_list.count_view_greater_20_days) + summonses_list.count_not_view_greater_20_days))::numeric, (0)::numeric))), (0)::numeric) AS percent_greater_20_days_all,
         COALESCE(round((((summonses_list.count_view_greater_20_days)::numeric * (100)::numeric) / NULLIF(((summonses_list.count_view_greater_20_days + summonses_list.count_not_view_greater_20_days))::numeric, (0)::numeric))), (0)::numeric) AS percent_view_greater_20_days,
         COALESCE(round((((summonses_list.count_not_view_greater_20_days)::numeric * (100)::numeric) / NULLIF(((summonses_list.count_view_greater_20_days + summonses_list.count_not_view_greater_20_days))::numeric, (0)::numeric))), (0)::numeric) AS percent_not_view_greater_20_days
        FROM summonses_list_subsystem.summonses_list;
        """), where);
    }

    /**
     * Create an aliased
     * <code>summonses_list_subsystem.view_summonses_list</code> table reference
     */
    public ViewSummonsesList(String alias) {
        this(DSL.name(alias), VIEW_SUMMONSES_LIST);
    }

    /**
     * Create an aliased
     * <code>summonses_list_subsystem.view_summonses_list</code> table reference
     */
    public ViewSummonsesList(Name alias) {
        this(alias, VIEW_SUMMONSES_LIST);
    }

    /**
     * Create a <code>summonses_list_subsystem.view_summonses_list</code> table
     * reference
     */
    public ViewSummonsesList() {
        this(DSL.name("view_summonses_list"), null);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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