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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of <code>metrics.view_fz_53_appeals</code>
     */
    public static final ViewFz_53Appeals VIEW_FZ_53_APPEALS = new ViewFz_53Appeals();

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

    /**
     * The column <code>metrics.view_fz_53_appeals.fz_53_appeals_id</code>.
     */
    public final TableField<ViewFz_53AppealsRecord, Long> FZ_53_APPEALS_ID = createField(DSL.name("fz_53_appeals_id"), SQLDataType.BIGINT, this, "");

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

    /**
     * The column <code>metrics.view_fz_53_appeals.percent_accepted</code>.
     */
    public final TableField<ViewFz_53AppealsRecord, BigDecimal> PERCENT_ACCEPTED = createField(DSL.name("percent_accepted"), SQLDataType.NUMERIC, this, "");

    /**
     * The column <code>metrics.view_fz_53_appeals.percent_refused</code>.
     */
    public final TableField<ViewFz_53AppealsRecord, BigDecimal> PERCENT_REFUSED = createField(DSL.name("percent_refused"), SQLDataType.NUMERIC, this, "");

    /**
     * The column <code>metrics.view_fz_53_appeals.percent_partially</code>.
     */
    public final TableField<ViewFz_53AppealsRecord, BigDecimal> PERCENT_PARTIALLY = createField(DSL.name("percent_partially"), SQLDataType.NUMERIC, this, "");

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

    private ViewFz_53Appeals(Name alias, Table<ViewFz_53AppealsRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_fz_53_appeals" as  SELECT fz_53_appeals.fz_53_appeals_id,
         ((fz_53_appeals.count_accepted + fz_53_appeals.count_refused) + fz_53_appeals.count_partially) AS count_all,
         COALESCE(round((((fz_53_appeals.count_accepted)::numeric * (100)::numeric) / NULLIF((((fz_53_appeals.count_accepted + fz_53_appeals.count_refused) + fz_53_appeals.count_partially))::numeric, (0)::numeric))), (0)::numeric) AS percent_accepted,
         COALESCE(round((((fz_53_appeals.count_refused)::numeric * (100)::numeric) / NULLIF((((fz_53_appeals.count_accepted + fz_53_appeals.count_refused) + fz_53_appeals.count_partially))::numeric, (0)::numeric))), (0)::numeric) AS percent_refused,
         COALESCE(round((((fz_53_appeals.count_partially)::numeric * (100)::numeric) / NULLIF((((fz_53_appeals.count_accepted + fz_53_appeals.count_refused) + fz_53_appeals.count_partially))::numeric, (0)::numeric))), (0)::numeric) AS percent_partially
        FROM metrics.fz_53_appeals;
        """), where);
    }

    /**
     * Create an aliased <code>metrics.view_fz_53_appeals</code> table reference
     */
    public ViewFz_53Appeals(String alias) {
        this(DSL.name(alias), VIEW_FZ_53_APPEALS);
    }

    /**
     * Create an aliased <code>metrics.view_fz_53_appeals</code> table reference
     */
    public ViewFz_53Appeals(Name alias) {
        this(alias, VIEW_FZ_53_APPEALS);
    }

    /**
     * Create a <code>metrics.view_fz_53_appeals</code> table reference
     */
    public ViewFz_53Appeals() {
        this(DSL.name("view_fz_53_appeals"), null);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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