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


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

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>registration_change_address.view_records_about_registrated_citizen</code>
     */
    public static final ViewRecordsAboutRegistratedCitizen VIEW_RECORDS_ABOUT_REGISTRATED_CITIZEN = new ViewRecordsAboutRegistratedCitizen();

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

    /**
     * The column
     * <code>registration_change_address.view_records_about_registrated_citizen.records_about_registrated_citizen_id</code>.
     */
    public final TableField<ViewRecordsAboutRegistratedCitizenRecord, Long> RECORDS_ABOUT_REGISTRATED_CITIZEN_ID = createField(DSL.name("records_about_registrated_citizen_id"), SQLDataType.BIGINT, this, "");

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

    /**
     * The column
     * <code>registration_change_address.view_records_about_registrated_citizen.percent_registrated_by_app_vk</code>.
     */
    public final TableField<ViewRecordsAboutRegistratedCitizenRecord, BigDecimal> PERCENT_REGISTRATED_BY_APP_VK = createField(DSL.name("percent_registrated_by_app_vk"), SQLDataType.NUMERIC, this, "");

    /**
     * The column
     * <code>registration_change_address.view_records_about_registrated_citizen.percent_registrated_another_vk</code>.
     */
    public final TableField<ViewRecordsAboutRegistratedCitizenRecord, BigDecimal> PERCENT_REGISTRATED_ANOTHER_VK = createField(DSL.name("percent_registrated_another_vk"), SQLDataType.NUMERIC, this, "");

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

    private ViewRecordsAboutRegistratedCitizen(Name alias, Table<ViewRecordsAboutRegistratedCitizenRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "view_records_about_registrated_citizen" as  SELECT records_about_registrated_citizen.records_about_registrated_citizen_id,
         (records_about_registrated_citizen.count_registrated_by_app_vk + records_about_registrated_citizen.count_registrated_another_vk) AS count_all,
         COALESCE(round((((records_about_registrated_citizen.count_registrated_by_app_vk)::numeric * (100)::numeric) / NULLIF(((records_about_registrated_citizen.count_registrated_by_app_vk + records_about_registrated_citizen.count_registrated_another_vk))::numeric, (0)::numeric))), (0)::numeric) AS percent_registrated_by_app_vk,
         COALESCE(round((((records_about_registrated_citizen.count_registrated_another_vk)::numeric * (100)::numeric) / NULLIF(((records_about_registrated_citizen.count_registrated_by_app_vk + records_about_registrated_citizen.count_registrated_another_vk))::numeric, (0)::numeric))), (0)::numeric) AS percent_registrated_another_vk
        FROM registration_change_address.records_about_registrated_citizen;
        """), where);
    }

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

    /**
     * Create an aliased
     * <code>registration_change_address.view_records_about_registrated_citizen</code>
     * table reference
     */
    public ViewRecordsAboutRegistratedCitizen(Name alias) {
        this(alias, VIEW_RECORDS_ABOUT_REGISTRATED_CITIZEN);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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