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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>summonses_list_subsystem.view_requests_direct_to_pers_acc</code>
     */
    public static final ViewRequestsDirectToPersAcc VIEW_REQUESTS_DIRECT_TO_PERS_ACC = new ViewRequestsDirectToPersAcc();

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

    /**
     * The column
     * <code>summonses_list_subsystem.view_requests_direct_to_pers_acc.requests_direct_to_pers_acc_id</code>.
     */
    public final TableField<ViewRequestsDirectToPersAccRecord, Long> REQUESTS_DIRECT_TO_PERS_ACC_ID = createField(DSL.name("requests_direct_to_pers_acc_id"), SQLDataType.BIGINT, this, "");

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

    /**
     * The column
     * <code>summonses_list_subsystem.view_requests_direct_to_pers_acc.percent_registered</code>.
     */
    public final TableField<ViewRequestsDirectToPersAccRecord, BigDecimal> PERCENT_REGISTERED = createField(DSL.name("percent_registered"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list_subsystem.view_requests_direct_to_pers_acc.percent_not_registered</code>.
     */
    public final TableField<ViewRequestsDirectToPersAccRecord, BigDecimal> PERCENT_NOT_REGISTERED = createField(DSL.name("percent_not_registered"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list_subsystem.view_requests_direct_to_pers_acc.percent_registered_formed</code>.
     */
    public final TableField<ViewRequestsDirectToPersAccRecord, BigDecimal> PERCENT_REGISTERED_FORMED = createField(DSL.name("percent_registered_formed"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>summonses_list_subsystem.view_requests_direct_to_pers_acc.percent_not_registered_formed</code>.
     */
    public final TableField<ViewRequestsDirectToPersAccRecord, BigDecimal> PERCENT_NOT_REGISTERED_FORMED = createField(DSL.name("percent_not_registered_formed"), SQLDataType.NUMERIC, this, "");

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

    private ViewRequestsDirectToPersAcc(Name alias, Table<ViewRequestsDirectToPersAccRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_requests_direct_to_pers_acc" as  SELECT requests_direct_to_pers_acc.requests_direct_to_pers_acc_id,
         (requests_direct_to_pers_acc.count_registered + requests_direct_to_pers_acc.count_not_registered) AS count_all,
         COALESCE(round((((requests_direct_to_pers_acc.count_registered)::numeric * (100)::numeric) / NULLIF(((requests_direct_to_pers_acc.count_registered + requests_direct_to_pers_acc.count_not_registered))::numeric, (0)::numeric))), (0)::numeric) AS percent_registered,
         COALESCE(round((((requests_direct_to_pers_acc.count_not_registered)::numeric * (100)::numeric) / NULLIF(((requests_direct_to_pers_acc.count_registered + requests_direct_to_pers_acc.count_not_registered))::numeric, (0)::numeric))), (0)::numeric) AS percent_not_registered,
         COALESCE(round((((requests_direct_to_pers_acc.count_registered_formed)::numeric * (100)::numeric) / NULLIF((requests_direct_to_pers_acc.count_registered)::numeric, (0)::numeric))), (0)::numeric) AS percent_registered_formed,
         COALESCE(round((((requests_direct_to_pers_acc.count_not_registered_formed)::numeric * (100)::numeric) / NULLIF((requests_direct_to_pers_acc.count_not_registered)::numeric, (0)::numeric))), (0)::numeric) AS percent_not_registered_formed
        FROM summonses_list_subsystem.requests_direct_to_pers_acc;
        """), where);
    }

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

    /**
     * Create an aliased
     * <code>summonses_list_subsystem.view_requests_direct_to_pers_acc</code>
     * table reference
     */
    public ViewRequestsDirectToPersAcc(Name alias) {
        this(alias, VIEW_REQUESTS_DIRECT_TO_PERS_ACC);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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