<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9
                      http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
					  

	
	<changeSet id="0001" author="saliakhov">
        <comment>edit view</comment>
		<sql>
			CREATE OR REPLACE VIEW deregistration.view_solutions
			AS SELECT solutions.solutions_id,
				solutions.count_accepted_signed + solutions.count_accepted_for_sign + solutions.count_refused AS count_accepted_all,
				COALESCE(round(solutions.count_accepted_for_sign::numeric * 100::numeric / NULLIF((solutions.count_accepted_signed + solutions.count_accepted_for_sign + solutions.count_refused)::numeric, 0::numeric)), 0::numeric) AS percent_accepted_for_sign,
				COALESCE(round(solutions.count_accepted_signed::numeric * 100::numeric / NULLIF((solutions.count_accepted_signed + solutions.count_accepted_for_sign + solutions.count_refused)::numeric, 0::numeric)), 0::numeric) AS percent_accepted_signed,
				COALESCE(round(solutions.count_refused::numeric * 100::numeric / NULLIF((solutions.count_accepted_signed + solutions.count_accepted_for_sign + solutions.count_refused)::numeric, 0::numeric)), 0::numeric) AS percent_refused
			   FROM deregistration.solutions;
		</sql>
	</changeSet>
</databaseChangeLog>