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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>registration_change_address.view_summonses_sign</code>
     */
    public static final ViewSummonsesSign VIEW_SUMMONSES_SIGN = new ViewSummonsesSign();

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

    /**
     * The column
     * <code>registration_change_address.view_summonses_sign.summonses_sign_id</code>.
     */
    public final TableField<ViewSummonsesSignRecord, Long> SUMMONSES_SIGN_ID = createField(DSL.name("summonses_sign_id"), SQLDataType.BIGINT, this, "");

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

    /**
     * The column
     * <code>registration_change_address.view_summonses_sign.percent_refused_in_second</code>.
     */
    public final TableField<ViewSummonsesSignRecord, BigDecimal> PERCENT_REFUSED_IN_SECOND = createField(DSL.name("percent_refused_in_second"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>registration_change_address.view_summonses_sign.percent_accepted_in_second</code>.
     */
    public final TableField<ViewSummonsesSignRecord, BigDecimal> PERCENT_ACCEPTED_IN_SECOND = createField(DSL.name("percent_accepted_in_second"), SQLDataType.NUMERIC, this, "");

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

    private ViewSummonsesSign(Name alias, Table<ViewSummonsesSignRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_summonses_sign" as  SELECT summonses_sign.summonses_sign_id,
         (summonses_sign.count_refused_in_second + summonses_sign.count_accepted_in_second) AS count_all,
         COALESCE(round((((summonses_sign.count_refused_in_second)::numeric * (100)::numeric) / NULLIF(((summonses_sign.count_refused_in_second + summonses_sign.count_accepted_in_second))::numeric, (0)::numeric))), (0)::numeric) AS percent_refused_in_second,
         COALESCE(round((((summonses_sign.count_accepted_in_second)::numeric * (100)::numeric) / NULLIF(((summonses_sign.count_refused_in_second + summonses_sign.count_accepted_in_second))::numeric, (0)::numeric))), (0)::numeric) AS percent_accepted_in_second
        FROM registration_change_address.summonses_sign;
        """), where);
    }

    /**
     * Create an aliased
     * <code>registration_change_address.view_summonses_sign</code> table
     * reference
     */
    public ViewSummonsesSign(String alias) {
        this(DSL.name(alias), VIEW_SUMMONSES_SIGN);
    }

    /**
     * Create an aliased
     * <code>registration_change_address.view_summonses_sign</code> table
     * reference
     */
    public ViewSummonsesSign(Name alias) {
        this(alias, VIEW_SUMMONSES_SIGN);
    }

    /**
     * Create a <code>registration_change_address.view_summonses_sign</code>
     * table reference
     */
    public ViewSummonsesSign() {
        this(DSL.name("view_summonses_sign"), null);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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