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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>registration_change_address.view_change_data_from_gir_vu</code>
     */
    public static final ViewChangeDataFromGirVu VIEW_CHANGE_DATA_FROM_GIR_VU = new ViewChangeDataFromGirVu();

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

    /**
     * The column
     * <code>registration_change_address.view_change_data_from_gir_vu.change_data_from_gir_vu_id</code>.
     */
    public final TableField<ViewChangeDataFromGirVuRecord, Long> CHANGE_DATA_FROM_GIR_VU_ID = createField(DSL.name("change_data_from_gir_vu_id"), SQLDataType.BIGINT, this, "");

    /**
     * The column
     * <code>registration_change_address.view_change_data_from_gir_vu.percent_requested_to_send</code>.
     */
    public final TableField<ViewChangeDataFromGirVuRecord, BigDecimal> PERCENT_REQUESTED_TO_SEND = createField(DSL.name("percent_requested_to_send"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>registration_change_address.view_change_data_from_gir_vu.percent_accepted_to_send_from_first</code>.
     */
    public final TableField<ViewChangeDataFromGirVuRecord, BigDecimal> PERCENT_ACCEPTED_TO_SEND_FROM_FIRST = createField(DSL.name("percent_accepted_to_send_from_first"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>registration_change_address.view_change_data_from_gir_vu.percent_denied_requests</code>.
     */
    public final TableField<ViewChangeDataFromGirVuRecord, BigDecimal> PERCENT_DENIED_REQUESTS = createField(DSL.name("percent_denied_requests"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>registration_change_address.view_change_data_from_gir_vu.percent_requested_solution_send_signed</code>.
     */
    public final TableField<ViewChangeDataFromGirVuRecord, BigDecimal> PERCENT_REQUESTED_SOLUTION_SEND_SIGNED = createField(DSL.name("percent_requested_solution_send_signed"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>registration_change_address.view_change_data_from_gir_vu.percent_requested_unloaded</code>.
     */
    public final TableField<ViewChangeDataFromGirVuRecord, BigDecimal> PERCENT_REQUESTED_UNLOADED = createField(DSL.name("percent_requested_unloaded"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>registration_change_address.view_change_data_from_gir_vu.percent_requested_solutions_formed</code>.
     */
    public final TableField<ViewChangeDataFromGirVuRecord, BigDecimal> PERCENT_REQUESTED_SOLUTIONS_FORMED = createField(DSL.name("percent_requested_solutions_formed"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>registration_change_address.view_change_data_from_gir_vu.percent_solutions_registration_signed</code>.
     */
    public final TableField<ViewChangeDataFromGirVuRecord, BigDecimal> PERCENT_SOLUTIONS_REGISTRATION_SIGNED = createField(DSL.name("percent_solutions_registration_signed"), SQLDataType.NUMERIC, this, "");

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

    private ViewChangeDataFromGirVu(Name alias, Table<ViewChangeDataFromGirVuRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_change_data_from_gir_vu" as  SELECT change_data_from_gir_vu.change_data_from_gir_vu_id,
         COALESCE(round((((change_data_from_gir_vu.count_requested_to_send)::numeric * (100)::numeric) / NULLIF((change_data_from_gir_vu.count_all)::numeric, (0)::numeric))), (0)::numeric) AS percent_requested_to_send,
         COALESCE(round((((change_data_from_gir_vu.count_accepted_to_send_from_first)::numeric * (100)::numeric) / NULLIF((change_data_from_gir_vu.count_all)::numeric, (0)::numeric))), (0)::numeric) AS percent_accepted_to_send_from_first,
         COALESCE(round((((change_data_from_gir_vu.count_denied_requests)::numeric * (100)::numeric) / NULLIF((change_data_from_gir_vu.count_all)::numeric, (0)::numeric))), (0)::numeric) AS percent_denied_requests,
         COALESCE(round((((change_data_from_gir_vu.count_solution_send_signed)::numeric * (100)::numeric) / NULLIF((change_data_from_gir_vu.count_all)::numeric, (0)::numeric))), (0)::numeric) AS percent_requested_solution_send_signed,
         COALESCE(round((((change_data_from_gir_vu.count_unloaded)::numeric * (100)::numeric) / NULLIF((change_data_from_gir_vu.count_all)::numeric, (0)::numeric))), (0)::numeric) AS percent_requested_unloaded,
         COALESCE(round((((change_data_from_gir_vu.count_solutions_registration_formed)::numeric * (100)::numeric) / NULLIF((change_data_from_gir_vu.count_all)::numeric, (0)::numeric))), (0)::numeric) AS percent_requested_solutions_formed,
         COALESCE(round((((change_data_from_gir_vu.count_solutions_registration_signed)::numeric * (100)::numeric) / NULLIF((change_data_from_gir_vu.count_all)::numeric, (0)::numeric))), (0)::numeric) AS percent_solutions_registration_signed
        FROM registration_change_address.change_data_from_gir_vu;
        """), where);
    }

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

    /**
     * Create an aliased
     * <code>registration_change_address.view_change_data_from_gir_vu</code>
     * table reference
     */
    public ViewChangeDataFromGirVu(Name alias) {
        this(alias, VIEW_CHANGE_DATA_FROM_GIR_VU);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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